Script with the following exception handling:
1. Unable to create ".tgz" the file
2. Unable to write the output to a file obtained from FTP client.
3. Unable to upload the file to remote host.
4. Send the current status to the recipient.
#!/bin/ksh
#-----
C
ta
if [ $? -eq 0 ]
then
(ftp -v -n remoteHostName <<!
user userName password
hash
bin
put ftpUploadFile.tgz
bye
!
) > output.txt 2>&1
if [ -f output.txt ]
then
if [ $? -eq 0 ]
then
echo "Submitted the file file.tgz successfully" |\
mail -s"Submitted the file" recipient@mailIdHostName
else
cat output.txt |\
mail -s"ftp failed with the submission of the file file.tgz" recipient@mailIdHostName
fi
rm -f output.txt
else
echo "Unable to create the file output.txt on using ftp command in the directory $CWD" |\
mail -s"Unable to create the file output.txt on using ftp command." recipient@mailIdHostName
fi
else
echo "Unable to create the file ftpUploadFile.tgz in the directory $CWD" |\
mail -s"unable to create the file ftpUploadFile.tgz" recipient@mailIdHostName
fi
#---------
Main Topics
Browse All Topics





by: ahoffmannPosted on 2009-10-30 at 17:58:12ID: 25707854
tar zcf file.tgz dir1 dir2 dir3 && ftp -n <<EoF && mail -sconfirm me
open remote.ftp.host
user username
password password
cd somedir
bin
put file.tgz
quit
EoF