Error when running nohup in bash script

My bash/nohup experience is very limited, so I might be making a basic mistake.

I'm launching a background file monitor. (In case it matters, Sass is a CSS preprocessor that can monitor source files and automatically compile them into CSS when it detects changes.)

When I enter this at a shell prompt, it launches the Sass file monitor perfectly:

nohup sass --watch /data/sass/:/data/css/ > /var/log/sass.out 2> /var/log/sass.err &

But when I put it in a script like this (a simplified sample script for debugging):

COMMAND="[exactly the same command as above]"
echo `$COMMAND`

I get this error:

nohup: ignoring input and redirecting stderr to stdout
Errno::ENOENT: No such file or directory - > Use --trace for backtrace. >>> 
Sass is watching for changes. Press Ctrl-C to stop.

The same thing happens if I specify the full path /usr/bin/local/sass. Any idea where I'm going wrong?


You can't run a complex command (eg with redirection) via:

echo `$COMMAND`

You can only really do this if you are running a simple binary or script. Your $COMMAND needs to be expanded properly before executing, so you need to run:

echo `eval $COMMAND`
链接地址: http://www.djcxy.com/p/56864.html

上一篇: Bash:如何

下一篇: 在bash脚本中运行nohup时出错