I got this error while running my script with nohup sh:
syntax error near unexpected token `('
My script is as follow:
#!/bin/bash
report_log="report.log";
grep -A 3 'successful\|ERROR COUNT EXCEEDED' *.log > ${report_log};
echo ${report_log};
MAX_ERR_COUNT_EXCEED_MSG="No Max Count Error.";
if grep "ERROR COUNT EXCEEDED" ${report_log}; then
MAX_ERR_COUNT_EXCEED_MSG="MAX ERROR COUNT EXCEEDED, CHECK RECORD COUNT!";
fi
RESULT_MSG="Execution successful";
if grep '\([1-9]\d*\b\)' ${report_log} | grep 'data errors'; then
RESULT_MSG="Execution with ERROR";
fi
cat ${report_log} <(echo "-----------") <(echo "${MAX_ERR_COUNT_EXCEED_MSG}") <(echo "${RESULT_MSG}") | mailx -s "Test Result" [email protected]
It is a script to filter through some log files and generate a reporting email on the execution status from those files.
The error seems to come from the usage of <(
in the script, but having added the bash shebang i thought it should work. The script run without issue if running using the command below:
. ./script.sh
Any help or advice is appreciated. Thanks.
nohup sh /path/to/your/script.sh
or asnohup /path/to/your/script.sh
? In the first case the shebang line is ignored because the interpreter is called explicitly.nohup sh /path/to/script
. In that case is there anyway i can overwrite the interpreter? This is because this script is called by another script and generally others run those scripts usingnohup sh
nohup /path/to/script
i get an errornohup: cannot run command 'script.sh': No such file or directory
insteadnohup bash /path/to/myscript.sh
?