在脚本中出现此错误:
g++: error trying to exec 'as': execvp: No such file or directory
编译的行:
/usr/bin/g++ -o $PATH/calc/calc $PATH/calc/calc.cpp
编辑:
剧本:
#!/bin/bash
clear
PATH="/media/joris/LinuxDomenai/Cpliuspliusprog"
echo Path yra $PATH
echo Koks filename?
read failas
echo $PATH/$failas/$failas.cpp
echo filename?
read failoname
PATH2="/media/joris/LinuxDomenai/Cpliuspliusprog"
/usr/bin/g++ -o "$PATH2/calc/calc" "$PATH2/calc/calc.cpp"
答案1
您不应该$PATH
在脚本中覆盖。
尝试一下,别忘了双引号:
MY_PATH="/your/path"
/usr/bin/g++ -o "$MY_PATH/calc/calc" "$MY_PATH/calc/calc.cpp"
修正脚本:
#!/bin/bash
clear
path_1="/media/joris/LinuxDomenai/Cpliuspliusprog"
echo "Path yra $path_1"
echo "Koks filename?"
read failas
echo "$path_1/$failas/$failas.cpp"
echo "filename?"
read failoname
path_2="/media/joris/LinuxDomenai/Cpliuspliusprog"
g++ -o "$path_2/calc/calc" "$path_2/calc/calc.cpp"