![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| checking exit status of a shell script | kdipankar | Shell Programming and Scripting | 2 | 05-08-2006 10:08 PM |
| Checking Exit Status | PrimeRibAndADew | Shell Programming and Scripting | 4 | 10-19-2005 12:01 PM |
| Sending mail, status checking | videsh77 | UNIX for Dummies Questions & Answers | 1 | 01-07-2005 05:17 AM |
| Checking the exit status of ftp | psingh | UNIX for Advanced & Expert Users | 1 | 06-04-2002 07:51 PM |
| Couldn't open status file /var/samba/STATUS.LCK | macdonto | UNIX for Dummies Questions & Answers | 2 | 08-08-2001 05:42 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
checking the status of file ftp
Hi,
I m new to unix and I need a help in FTp-ing a file. My script is given below ftp -n <<END_SCRIPT open $FTP_HOST user $FTP_USER $FTP_PASSWD lcd $TEMPFOLDER cd $FTP_LOCATION put $1 bye END_SCRIPT exit_status=$? if [ "$exit_status" -eq "0" ] ; then log "successfully FTPed the file" else log "Failed to FTP the report file" fi But the exit _status check doesnt seem to be working. I mean if the FTP_HOST name is given invalid, the exit_status still shows zero. Can anyone pls tell me how else can I check for the successfult FTP of the file.. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
If your ftp client doesn't set its exit status properly, try switch to a different one. ncftp and lftp are fairly popular, and at least the latter has some scripting support of its own.
|
|
#3
|
|||
|
|||
|
This might work, try out this way,
ftp -n $FTP_HOST <<END_SCRIPT user $FTP_USER $FTP_PASSWD lcd $TEMPFOLDER cd $FTP_LOCATION put $1 bye END_SCRIPT exit_status=$? if [ "$exit_status" -eq "0" ] ; then log "successfully FTPed the file" else log "Failed to FTP the report file" fi |
|
#4
|
|||
|
|||
|
Thanks. But that option is not working for me. It just displays the error message in console as "unknown host or invalid literal address".
But the exit_status still shows as zero |
|
#5
|
|||
|
|||
|
No exit status error codes are defined for ftp by any standard that I am aware of. Therefore you cannot safely use $? to check exit status for errors unless your specific version of ftp supports such exit status error codes.
You need to use expect or a similar TCL to script the ftp session if you want to be able to detect session errors. |
|
#6
|
|||
|
|||
|
First off ftp is a protocol that is defined by RFC 959. This defines status reply codes, those numbers you see like 204. These are what you look for to determine what happened. Just checking the return code will not help anything in almost every case.
Quote:
|
|||
| Google The UNIX and Linux Forums |