regarding FTP

hi frnds..

hi have a FTP script..
How can i chk whether file/files has been ftp'd successfully.

coz if they are not.. I need to ftp it again...

pl hlp..

thanks.

anchal.

use ftp's "ls" command to check for the filename, put the whole thing in some "if then else" condition.
This is generic answer, since you didn't show the relevant parts of your script.

thanks for the reply.
but ..i didnt get what i can get with "ls".

..
actually my prob is that I wnt to chk for the file size..if its zero KB thn I need to ftp it again....and/or 'll send a mail..

so how can i chk for the file size on ftp prompt..??

You can do ls -s in ftp

how can i implement this... :frowning:

if I m not wrong ls -s give the used space..... but it doesnt gives the size...

Its always better to map the checksum of the file .... at source and destination pool. if the checksum is matched... then ..file is copied successfully.. for sure..

Use " cksum " for the file size varification .

The -s option gives the file size in blocks, including indirect blocks, for each entry.

Other than some specified commands, you cannot use it in ftp mode. So better to delete zero byte files in the landing directory and start the ftp for those file again..

Need to see your code...........

this is the only FTP part of my scripts...
I faced 2-3 times that the files uploaded on the remote server is zero KB. and thsts coz of some connection prob... so if this happenes thn i need to test it and retranfer the files.
I heard about reget and reput.. but these commands are not working on my box.
I m using HP-UX.

Host=172.28.8.136
user=arbor
password=airy1est
LocalPath=$OutDir
RemotePath=/emm/spd/tmp
RemoteArchivePath=/emm/spd/out

ftp -ivn $Host > /tmp/ftp.success.log 2> /tmp/ftp.failed.log <<FTP
user $user $password
binary
cd $RemotePath
lcd $LocalPath
mput *PARTIAL_${PROCESSDATE}.bcp.gz
rename ${RemotePath}/External_ID_PARTIAL_${PROCESSDATE}.bcp.gz ${RemoteArchivePath}/External_ID_PARTIAL_${PROCESSDATE}.bcp.gz
rename ${RemotePath}/EMF_PRODUCTS_PARTIAL_${PROCESSDATE}.bcp.gz ${RemoteArchivePath}/EMF_PRODUCTS_PARTIAL_${PROCESSDATE}.bcp.gz
rename ${RemotePath}/EMF_PRODUCTS_MVPN_PARTIAL_${PROCESSDATE}.bcp.gz ${RemoteArchivePath}/EMF_PRODUCTS_MVPN_PARTIAL_${PROCESSDATE}.bcp.gz
rename ${RemotePath}/CMF_PRODUCTS_PARTIAL_${PROCESSDATE}.bcp.gz ${RemoteArchivePath}/CMF_PRODUCTS_PARTIAL_${PROCESSDATE}.bcp.gz
bye

FTP

@manaspatra : i m trying to get more info about ur soln... since i dont know much about this command.. hope ur soln helps me..

Dear Anchal,

i roughly modified the script. plz check if the script helps you...

Host=172.28.8.136
user=arbor
password=airy1est
LocalPath=$OutDir
RemotePath=/emm/spd/tmp
RemoteArchivePath=/emm/spd/out

ftp -i -v -n $Host <<-parameters_End > /tmp/ftp.success.log
user $user $password
status
bin
cd $RemotePath
lcd $LocalPath
mget *PARTIAL_${PROCESSDATE}.bcp.gz
bye
parameters_End

FTP_STATUS=`grep -i "Login incorrect" /tmp/ftp.success.log
FTP_STATUS1=`grep -i "Unknown host" /tmp/ftp.success.log
FTP_STATUS2=`grep -i "No such file or directory" /tmp/ftp.success.log

if [ -n "${FTP_STATUS}" ]
then
echo "Incorrect Login/Password in ftp" >> $SCRNDRLOG
fi

if [ -n "${FTP_STATUS1}" ]
then
echo "Unknown Host in ftp" >> $SCRNDRLOG
fi

if [ -n "${FTP_STATUS2}" ]
then
echo "File to download not found in the ftp server" >> $SCRNDRLOG
fi
mv ${RemotePath}/External_ID_PARTIAL_${PROCESSDATE}.bcp.gz ${RemoteArchivePath}/External_ID_PARTIAL_${PROCESSDATE}.bcp.gz
mv ${RemotePath}/EMF_PRODUCTS_PARTIAL_${PROCESSDATE}.bcp.gz ${RemoteArchivePath}/EMF_PRODUCTS_PARTIAL_${PROCESSDATE}.bcp.gz
mv ${RemotePath}/EMF_PRODUCTS_MVPN_PARTIAL_${PROCESSDATE}.bcp.gz ${RemoteArchivePath}/EMF_PRODUCTS_MVPN_PARTIAL_${PROCESSDATE}.bcp.gz
mv ${RemotePath}/CMF_PRODUCTS_PARTIAL_${PROCESSDATE}.bcp.gz ${RemoteArchivePath}/CMF_PRODUCTS_PARTIAL_${PROCESSDATE}.bcp.gz

Gud Luk
Regards,
Pankaj

Dear Anchal,
i forgot to place the exit command where ever ftp will get failed...
and plz avoid the $SCRNDRLOG file...

so follow the code for ftp connection faluire

if [ -n "${FTP_STATUS}" ]
then
echo "Incorrect Login/Password in ftp" >> $SCRNDRLOG
exit 3
fi

if [ -n "${FTP_STATUS1}" ]
then
echo "Unknown Host in ftp" >> $SCRNDRLOG
exit 3
fi

if [ -n "${FTP_STATUS2}" ]
then
echo "File to download not found in the ftp server" >> $SCRNDRLOG
exit 3
fi