The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Major OS errors/Bash errors help!!!! wcmmlynn UNIX for Dummies Questions & Answers 12 11-13-2007 04:50 AM
rcp error trapping in rsh vvejendla Shell Programming and Scripting 2 11-21-2005 11:29 PM
Adapter Errors and Link Errors mcastill66 AIX 2 08-02-2005 07:51 PM
Adapter Errors and Link Errors mcastill66 UNIX for Advanced & Expert Users 0 08-02-2005 07:11 PM
ftp error trapping Bab00shka UNIX for Dummies Questions & Answers 1 04-02-2002 12:21 PM

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

Join Date: Apr 2005
Posts: 51
trapping errors while using FTP.

Hello,

I have the following shell script to perform ftp:

ftp -n $HOST<<EOD
quote USER $USER
quote PASS $PASS
lcd $outputd
cd $dir
binary
put *.zip
quit
EOD

If any error is generated from this script then how to trap the error. For ex: let's say we entered wrong password then the return code from this shell script is always coming as 0. Even though there is a login error.

Do anybody have an idea how to trap ftp errors?

Appreciate your reply.
Radhika.
  #2 (permalink)  
Old 05-26-2005
jerardfjay jerardfjay is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 146
Quote:
Originally Posted by radhika

Do anybody have an idea how to trap ftp errors?

Appreciate your reply.
Radhika.
In general you could redirect the output STDOUT and STDERR of the ftp call to a log file and then query the log file for specific success or failure return codes to determine the status of the current ftp session. From this perspective you might have to create different log files for each ftp session and actively manage your logfiles too.

If there is any other way please advise. Thanks. Jerardfjay
  #3 (permalink)  
Old 05-26-2005
nimo
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Try this:

ftpresults=`ftp -inv $ip_box_name <<EOB
user $userid $password
put $ftp_file $downstream_name
bye
EOB`

ftp_ctr=`echo "$ftpresults" |grep "226" | wc -l`
echo $ftp_ctr
if [ $ftp_ctr = 1 ]
then
echo "FTP of " $file_name " to " $ip_box_name " was successful"
echo " "
else
echo="FTP failed"
fi

Last edited by nimo; 05-26-2005 at 07:17 PM..
  #4 (permalink)  
Old 05-26-2005
radhika radhika is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 51
I am sorry, what does $ftpresults have in it.

Is it like stdout and stderr from ftp.sh?
  #5 (permalink)  
Old 05-26-2005
nimo
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
My apology, I forgot part of the script in my editor. Please refer to my previous message for the script again.
  #6 (permalink)  
Old 05-27-2005
radhika radhika is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 51
ThankYou!!! All for your ideas and sample code. I am going to try them this morning.

Radhika.
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 11:45 PM.


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