I'm running a command like so, with the $OUTPUT
variable saving the results of the command. But I also want to save the command itself to a variable for inclusion in a status email.
OUTPUT=$(php -f $LOCATION/somefile.php -- -process "$INPUTFILE" 2>&1)
The first part works. Then I tried this:
IMPORTCOMMAND='php -f' "$LOCATION"'/somefile.php -- -process'"$INPUTFILE"
But instead of saving the string to the variable, it seems to be just executing the command a second time.
EDIT:
Here is a mockup of how I create my email body. I have single quotes around regular strings and then double quotes around bash variables.
BODY='<b color="red">Output:</b><br />'"$OUTPUT"'<b color="red">Command:</b> '"$IMPORTCOMMAND"
After that I try to replace newlines with html "
" like so:
BODY="${BODY//$'\n'/<br />}"
#changed $BODY="" to BODY="" per yaegashi's suggestion
The following error disappeared after I followed yaegashi's suggestion:
/usr/local/bin/some-script.sh: line 59: <b: command not found
But the original error remains, at the IMPORTCOMMAND
variable assignment.
"$IMPORTCOMMAND"
when using it.$BODY
variable. It seems like the error occurs when I try to replace newlines with<br />
. Please see my edit.BODY="..."
. No heading$
.IMPORTCOMMAND='php -f' "$LOCATION"'/somefile.php -- -process'"$INPUTFILE"
line. The php script is being executed. I must be doing something wrong with the quotes up there.IMPORTCOMMAND='php -f '"$LOCATION"'/somefile.php -- -process '"$INPUTFILE"