I have the file named as: /home/cti/10min_test/CTI_poult_20240902005000.csv
and wrote this shell script below:
CURRENT_TIME=$(date -d "+1 hour +50 minutes" +%Y%m%d%H%M)
CURRENT_TIME_TRIMMED=${CURRENT_TIME:0:11}
FILE_NAME_PART=${CURRENT_TIME_TRIMMED}
echo "FILE_NAME_PART: ${FILE_NAME_PART}"
echo "SOAP PROJECT: Starting SFTP…"
lftp -d -u myuser,mypass sftp://myip:port <<EOF
mput /home/cti/10min_test/CTI_poult_${FILE_NAME_PART}*.csv
bye
EOF
echo "done"
And when this is executed, only shows this message:
FILE_NAME_PART: 20240902011
SOAP PROJECT: Starting SFTP…
*.csv: no files found_test/CTI_poult_20240902011
done
It seems "*.csv" is not properly processed by the script. Anyone could tell me what the heck is wrong?
/home/cti/10min_test/, but the error message hasfound_test/.CTI_poult_20240902011\r*.csv-- make sure the script file iteself does not contain\r\nline endings. Thedos2unixcommand is helpful.CTI_poult_20240902005000.csvdoesn't match your date code (date -d "+1 hour +50 minutes" +%Y%m%d%H%M,) Either you need to add%S, or remove the ending "Seconds stamp" of00.... better debugging can be achieved withset -x(set +xto disable) ANDexport PS4='${LINENO} >'(export PS4="+"is the default value) . It will show each Line of executed code with all env-vars, cmd-substitutions, etc, expanded so you know exactly what command the shell tried to Run. All dbl-quoted strings are "normalized" to single-quoted strings. Good luck.echobe also messed up, the second one overwriting the first? But you are right, in that it would make sense to make a hex dump of the script and look for stray carriage returns.printf %s "$FILE_NAME_PART" | oc -cxand look for CRs or other control characters.