I have a KornShell (ksh) script which writes out FTP script and executes to get some files from windows server to UNIX.
echo "user <username> <pwd>" >ftpin.out
echo "bin">>ftpin.out
echo "get file.txt" >>ftpin.out
echo "get file2.txt" >>ftpin.out
echo "!echo $?">>ftpin.out
echo"bye">>ftpin.out
ftp -n -i servername <ftpin.out
echo $?
Here I am not able to check if the file exists on the source Windows system or not. Because this usual error handling is not working and the $? is 0 always when any file is there and other is not there. I even tried checking for ERRORLEVEL but that is not working on UNIX(Solaris 10).
Can any one show samples of simple error handling for this which works or how to do it? Log file parsing was also taken into consideration but is there any other built in way? Other FTP mechanisms are out of scope. We are using plain old FTP.
Thanks for your responses. I am using the below method to make it work.
By the above method if FTP fails to copy one file if the file is not present in the source server then i will call alertme.sh script to mail me an error message.
This way I can even use it to overwrite the ftpin.out itself to stop the next get of a file in ftp. I am going to test the below one for this.
Thanks again. Hope this helps for any body facing similar difficulty.