![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get the exit status | yhacks | Shell Programming and Scripting | 1 | 05-19-2008 05:06 AM |
| 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 |
| tar exit status | thorndike | UNIX for Dummies Questions & Answers | 3 | 01-22-2002 12:39 PM |
| ftp exit status. | oracle8 | UNIX for Advanced & Expert Users | 1 | 10-21-2001 08:34 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Checking the exit status of ftp
#!/bin/sh
# upload_file.sh FILENAME=$1 ftp -v -n -i <<-EOF1 open remote_server user username password cd remote_directory lcd local_directory type binary mput ${FILENAME} EOF1 rc=$? echo "Return code is ${rc}" I am calling this script from another script. My problem is that the exit status of the above script is always 0, i.e. successful, even if remote_directory, local_directory or FILENAME don't exist. I want to check the exit status of this script in the calling script and take appropriate action based on whether the ftp was successful or not. I am not sure if I am doing something wrong. |
| Forum Sponsor | ||
|
|
|
|||
|
This is not so much as checking the exit code but a way to validate the transfer:
FILENAME=$1 ftp -v -n -i <<EOF > /tmp/ftplog.$$ <<<ftp stuff> EOF Then either in the upload script or in the calling script store the size of the file just tranferred into an environment variable using ls -l and awk. Then cat /tmp/ftplog.$$. You want to grep for the line that reads "XXX bytes transferred" (or however it reads. It's been a long time since I've done this) and awk out the "XXXX" bytes into a second environment variable. In the upload script it is simple to do a comparision and "exit 1" for an imcomplete or failed transfer. You could also cat/grep the tmplog for other error conditions such as failure to cd to the appropriate directories, etc. and exit with different return codes depending on the nature of the failure. Either way this should be enough information point in you in the best direction you need to validate your transfers. NOTE: this method works for binary transfers only. Ascii transfers show a lower number of bytes transfered. |
|||
| Google The UNIX and Linux Forums |