FTP in UNIX with Error Handling

This script will handle FTP in UNIX and errors also.

UNIX command $? Will not capture error status, so error message has to be written to a log file and then read.

error_log=/tmp/error_log.log
lc_server_name="your.ftp.server.name"
echo "1" $lc_server_name
ftp -i -n -d<<EOF >$error_log
open $lc_server_name
user userid password
bye
EOF
result=`grep -c 'Not connected.' error_log.log`
result1=`grep -c 'Login failed.' error_log.log`
echo $result
echo $result1
if [ ${result} -gt 0 -o ${result1} -gt 0 ]; then
echo "Connect to FTP failed"
else
echo "Connection Successful"

fi

No comments:

Post a Comment

How to find all cancel Requisitions

SELECT prha . *   FROM po_Requisition_headers_all prha , po_action_history pah   WHERE      1 = 1        AND pah . object_id ...