I am using AIX/Unix that is making two FTP calls one a simple FTP the other a Secure FTP (SFTP).
My script needs to be able to be able to determine if the FTP was successful or not. Does anyone have any ideas or examples on how I could try this? Right now, I'm just trying to test the connection by pinging the server. Once I get it to work, I'll expand it to use an FTP command. This is what I have so far
STATUS=`ping -v -c 1 servername` if [ "$(echo $STATUS | grep -c "NOT FOUND")" -ge 1 ] then echo "No Connection" else echo "Connection successful"
It works fine if I use the correct server name but if I alter the name to test the "NOT FOUND" condition, I still get a "Connection successful" message.
echo "${RESULT}" >> ${TMPFILE}
Thanks a lot! I'll see if I can get a version of this working today. I appreciate your assistance!
Here's an excerpt of the pertinent pieces of an sftp script
sftp -i ${ftpKey} -b - ${ftpUserID}@${ftpHost} < lcd ${LPath} cd ${RPath} get ${RFile} ${LFile} rm ${RFile} bye EOF sftpRC=$? echo ' ' echo ' SFTP Return Code: ' $sftpRC echo ' ' if [ $sftpRC == 0 ]; then echo ' SFTP Successful' echo ' ' else echo ' Error - SFTP Failed!' echo ' ' exit 9 fi
lcd ${LPath}
cd ${RPath}
get ${RFile} ${LFile}
rm ${RFile}
bye
EOF
sftpRC=$?
echo ' '
echo ' SFTP Return Code: ' $sftpRC
if [ $sftpRC == 0 ]; then
echo ' SFTP Successful'
else
echo ' Error - SFTP Failed!'
exit 9
fi