简体   繁体   English

在shell脚本中执行make命令的正确方法是什么?

[英]What is the proper way to execute a make command within a shell script?

I want to build a shell script to execute the following two commands, but the shell complains that it does not know about the parameters clean or reload. 我想构建一个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

I would like to make a variable out of the directory as well, but when trying to concat the directory and infx.mak I am having even more issues. 我也想从目录中创建一个变量,但是当尝试连接目录和infx.mak时,我遇到了更多问题。

Thanks for your help 谢谢你的帮助

Code and Errors: 代码和错误:

    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

The error message looks like you have DOS line endings in your script. 错误消息看起来像您的脚本中有DOS行结尾。 Try dos2unix or tr -d '\\015' to fix it. 尝试使用dos2unixtr -d '\\015'进行修复。 (Google for a bit if you need help; this is a very common problem.) (如果需要帮助,Google会提供一些帮助;这是一个非常常见的问题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM