[英]What is the proper way to execute a complex shell command within C++?
[英]What is the proper way to execute a make command within a shell script?
我想構建一個Shell腳本來執行以下兩個命令,但是Shell抱怨說它不知道參數clean或reload。
make -f '/home/ec2-user/infx/infx.mak' clean
make -f '/home/ec2-user/infx/infx.mak' reload > '/home/ec2-user/infx/mylog.txt' 2>&1
我也想從目錄中創建一個變量,但是當嘗試連接目錄和infx.mak時,我遇到了更多問題。
謝謝你的幫助
代碼和錯誤:
echo "Cleaning Project"
make -f '/home/ec2-user/infx/infx.mak' clean
echo "Making Project"
make -f '/home/ec2-user/infx/infx.mak' reload > '/home/ec2-user/infx/mylog.txt' 2>&1
srcdir='/home/ec2-user/infx'
srcmak='/infx.mak'
echo "$srcmak$srcdir"
exit 0
[ec2-user@ip infx]$ sudo ./reload.sh
'. Stop. No rule to make target `clean
: ambiguous redirect 1
/home/ec2-user/infx
錯誤消息看起來像您的腳本中有DOS行結尾。 嘗試使用dos2unix
或tr -d '\\015'
進行修復。 (如果需要幫助,Google會提供一些幫助;這是一個非常常見的問題。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.