By jimbojames
Hello.
When I run a .ksh that contains the command below, and there is no file available in the source location the “FILE_NAME_*.CSV not found” error is still being displayed.
Code:
FILEN=$(ssh ${SOURCE_SERV} "cd ${SOURCE_LOCATION} ;ls ${FILES}") 2> /dev/null
.
This is interfering with the rest of the script, as it is not exiting as required, and is continuing to the next command (See below).
Code:
echo "- Listing available file(s) on ${SOURCE_SERV}${SOURCE_LOCATION}:n"
FILEN=$(ssh ${SOURCE_SERV} "cd ${SOURCE_LOCATION} ;ls ${FILES}") 2> /dev/null
print ${FILEN}
if [ $? -eq 0 ]; then
echo "n- End of Source of files list."
else
echo "tt#####################################ntt# NO FILES AVAILABLE. #ntt#####################################nnn- Exiting script"
exit 0
fi
Can anyone advise what I am doing wrong with the redirection? Basically If there are no files available, I need to echo the warning and exit the script successfully.
Thanks in advance.
…read more
Source: FULL ARTICLE at The UNIX and Linux Forums