Issue
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?
Solution
You can't run a complex command (e.g. 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`
Answered By - ndbroadbent Answer Checked By - Katrina (WPSolving Volunteer)