The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to get the exit status yhacks Shell Programming and Scripting 1 05-19-2008 08:06 AM
checking exit status of a shell script kdipankar Shell Programming and Scripting 2 05-09-2006 01:08 AM
Checking Exit Status PrimeRibAndADew Shell Programming and Scripting 4 10-19-2005 03:01 PM
tar exit status thorndike UNIX for Dummies Questions & Answers 3 01-22-2002 04:39 PM
ftp exit status. oracle8 UNIX for Advanced & Expert Users 1 10-21-2001 11:34 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-17-2002
psingh psingh is offline
Registered User
  
 

Join Date: May 2002
Posts: 6
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.
  #2 (permalink)  
Old 06-04-2002
random random is offline
Registered User
  
 

Join Date: Jun 2002
Location: North Texas
Posts: 3
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0