is it possible to capture the 3 digit return code of ftp commands in a local variable inside a shell script?
Code:
ftp remoteserver << EOFTP
quote USER uid
quote PASS pass
prompt
cd remote_directory
mput file.txt
bye
EOFTP
in the above script, if cd command returns 550 in case of failure and 226 in case of success. same way mput also returns.. how cn i capture these return codes.
ftp -iv remoteserver<<EOFTP> ftp.log 2>&1
prompt
cd remote directory
mget file*.txt
ls -ltr
bye
EOFTP
After executing the above ftp.. Log file contains many replies from ftp.. For example� mget and ls -ltr both the command gives 226 as a reply for success..How can I know which reply is for which command.. N also the text after the reply codes are server dependent.
You could always insert your own trace information to help out.
You could add a pwd or dir for the remote server to process.
You could add a local command with a ! to put in a marker.
Have a go with this:-
ftp -inv remoteserver<<EOFTP> ftp.log 2>&1
user $userid $password
prompt
pwd
cd remote directory
pwd
dir
!echo "`date` Get files"
dir file*.txt
mget file*.txt
!echo "`date` Got files"
bye
EOFTP
Hopefully with these you can work out where the problem is. If you need to know as the process progresses, then you may have to connect several times, so you may have a first connection to prove that you can get to the directory, a second to list the files. You might then choose to get each file in a loop so if there are any failures, you know which one you are working on.
See if that helps, but if not let us know what else would be useful and I/we will see what can be done.