SubhaBabu
asked on
How to find the status of FTP operation inside shell script
My Shell Script looks like this .
# Copying the dat file to Pool Talk server
ftp -n $EPT_SERVER_NAME <<!
quote user $EPT_USER
quote pass $EPT_PASSWORD
binary
cd /ssss/ept$ENV/ddd/in/mbs
lcd /ffff/l7$ENV/sss/out/2006
put SchA.dat
!
# Copying the dat file to BloomBerg server
ftp -n $BBERG_SERVER_NAME <<!
quote user $BBERG_USER
quote pass $BBERG_PASSWORD
binary
cd /export/xxxx/wyyyy/zzz/ftp /dddd/mfdi sclose/inp ut/
lcd /appl/l7$ENV/data/out/2006
put MF_SCHEDA_*.dat
!
As it is obvious from the above code, that i am trying to ftp file to two different servers. Now i have a new requirement that says that if ftp to the first server succeeds, then i don't have to ftp the file to the next server. To achive that i need to know the status of the ftp operation. Please let me know how to find the status of the ftp operation inside shell script.
I tried $?, which i heard will give me the status of the last shell command. but in this case , i get 0 all the time even if the ftp fails to succeed. Please let me know the other solutions.
Thanks
Subha
# Copying the dat file to Pool Talk server
ftp -n $EPT_SERVER_NAME <<!
quote user $EPT_USER
quote pass $EPT_PASSWORD
binary
cd /ssss/ept$ENV/ddd/in/mbs
lcd /ffff/l7$ENV/sss/out/2006
put SchA.dat
!
# Copying the dat file to BloomBerg server
ftp -n $BBERG_SERVER_NAME <<!
quote user $BBERG_USER
quote pass $BBERG_PASSWORD
binary
cd /export/xxxx/wyyyy/zzz/ftp
lcd /appl/l7$ENV/data/out/2006
put MF_SCHEDA_*.dat
!
As it is obvious from the above code, that i am trying to ftp file to two different servers. Now i have a new requirement that says that if ftp to the first server succeeds, then i don't have to ftp the file to the next server. To achive that i need to know the status of the ftp operation. Please let me know how to find the status of the ftp operation inside shell script.
I tried $?, which i heard will give me the status of the last shell command. but in this case , i get 0 all the time even if the ftp fails to succeed. Please let me know the other solutions.
Thanks
Subha
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.