I have a script, which is checking if file exists and move it to another directory
if [ -f report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ]
then
mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly
mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly
${LOCL_WORKING_DIR}/sftp_ondemand_monthly.sh /export/applications/ibm6000/mbsesb/config/ondemand.cfg /export/applications/ibm6000/mbsesb/config/filename.lst
else
echo "There is no report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv file ${Today}"
fi
Strange, but the directory is not created
Could you please let me know what is wrong with my script?
have you tried adding set -x to the script and tracing its execution?
I can see a potential issue with -f report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv statement...
No, I put print statement inside. I goes inside if statement, prints everything, but doesn't start the script
if [ -f report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ]
then
echo "We are in report" >> ${LOGF}
mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly
mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR
}/cool_${Today}/monthly
echo "Before sftp_ondemand_monthly.sh">>${LOGF}
echo "${LOCL_WORKING_DIR}/sftp_ondemand_monthly.sh /export/applications/
ibm6000/mbsesb/config/ondemand.cfg /export/applications/ibm6000/mbsesb/config/filename.lst" >>${LOGF}
${LOCL_WORKING_DIR}/sftp_ondemand_monthly.sh /export/applications/ibm600
0/mbsesb/config/ondemand.cfg /export/applications/ibm6000/mbsesb/config/filename.lst
echo "After sftp_ondemand_monthly.sh">>${LOGF}
else
echo "There is no report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv file ${Today}"
fi
OUTPUT
We are in report
Before sftp_ondemand_monthly.sh
/export/applications/ibm6000/mbsesb/sh/sftp_ondemand_monthly.sh /export/applications/ibm6000/mbsesb/config/ondemand.cfg /export/applications/ibm6000/mbsesb/config/filename.lst
After sftp_ondemand_monthly.sh
I'd suggest adding set -x to the "master" script and to the /export/applications/ibm6000/mbsesb/sh/sftp_ondemand_monthly.sh script to trace their execution. This makes tracing much easier and will "flag" any potential issues with variable expansion and/or test statements...
strange, your version of the script mentions /export/applications/ibm6000/mbsesb/sh/sftp_ondemand_monthly.sh and not ondemand_sftp_monthly.sh .
Does the enabled tracing help identifying a potential issue?
Saying Just don't execute isn't really helpful....
Don't think so. Shell languages don't silently skip statements, so either your script is run (and you didn't notice it) or you get an error (and you didn't notice it).
I would like to see again
The content of the script you are debugging
The way you are invoking it
The complete output of the run with -x
For example you could do a
cat yourscript.sh
bash -x yourscript.sh
and post here a link to, for instance, a screenshot of the result.