FTP error handling - critical


 
Thread Tools Search this Thread
Operating Systems Solaris FTP error handling - critical
# 8  
Old 11-01-2010
Maybe not so valuable info, but some providers offer also CVS hosting, it should be probably what U'r looking for. Ask our provider for that.
# 9  
Old 11-01-2010
We are off topic here.

ftp provides return codes. It does not return an error to the shell normally. If you read the responses from ftp you can determine on a per file basis the status of each transfer.

Lets' start with this:
List of FTP server return codes - Wikipedia, the free encyclopedia

1nn == acknowledgement of your request
2nn == sucess
3nn 4nn == problems

This is a simplifcation, but it works for most situations
Since you are interested in all files, you have to track each file transfer and look for an error.
mput will give errors as well, plus when you use mput, you need the -i option
Code:
ftp -i -n

The reason for one-at-a-time is so you can pick up where you left off, plus I am assuming the files are large, so ftp reconnects take only a tiny amount of time compared to transfers.

Code:
#!/bin/sh
#
BACKUPDIR="/export/home/myuser/backup"
status=0
HOST='ftp.xyz.com'
USER='user@xyz.com'
PASSWD='abc'
#FILE='*.gz'

for FILE in *.fz
do
    status=0
    echo "Processing $FILE"
    ftp -n $HOST <<END_SCRIPT  | grep '^2' && status=1
    quote USER $USER
    quote PASS $PASSWD
    verbose
    lcd $BACKUPDIR
    cd backups/source
    binary
    put $FILE
    quit
    bye
END_SCRIPT
    if [[ $status -eq 0 ]] ; then
       echo "$FILE failed to transfer"
       break       # this makes the code end early
    else
      echo "$FILE sent ok"
    fi   
done
if [[ $status -eq  1 ]] ; then
   cd $BACKUPDIR
   rm *.gz
   echo 'successful completion'
else
   echo 'Failure.'
   exit 1                          
fi
exit 0

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

Moving SCO Virtual Machine in VMWare Environment: Critical Licensing Error Messages

Some years ago our company chose to run a critical proprietary app under SCO Unix. My predecessor tried to move A SCO Unix virtual machine from our dedicated VMWare environment to a shared Cloud VMWare environment. My predecessor received licensing messages from these critical servers so... (2 Replies)
Discussion started by: timfox1234
2 Replies

2. Shell Programming and Scripting

Script FTP maintain error handling

Hi, I have ftp script like below How to insert an error handling, If the transfer failed then send mail to me. Actually, I just need the script to send an email if the FTP failed. How to put the email script within FTP script? Thank You Edy (5 Replies)
Discussion started by: edydsuranta
5 Replies

3. Shell Programming and Scripting

Error handling

Hello fellow UNIX gurus :) I have a problem regarding the script below: # Variables used in this shell. power=0 # Stores squared integer total=0 # Sum of all squared integers num=0 # Stores command line arguements # Provides error handling if command line... (5 Replies)
Discussion started by: Learn4Life
5 Replies

4. UNIX for Dummies Questions & Answers

File not found handling in ftp script

I have a pattern for filename to be searched. I need to get the files from remote server Who are matching the file pattern. And i need to exit with non zero return code for: 1)No files found matching that pattern 2)More than one files matching the name pattern. If only one files is... (1 Reply)
Discussion started by: pandeesh
1 Replies

5. UNIX for Dummies Questions & Answers

Error in terminal: Gtk-CRITICAL

Hi, I am using Ubuntu 10.04. Recently I have seen this error appear in my terminal as I edit text files with gedit: (gedit:2841): Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion `ancestor != NULL' failed Any ideas on what this means? Mike (1 Reply)
Discussion started by: msb65
1 Replies

6. Shell Programming and Scripting

Error Handling

Helo Experts, I need a help in handling errors in shell script, wants my errors displayed in text file instead of command window.. My shell script is here; cd /cygdrive/s/Files for FILES in ./*.* do temp=`basename $FILES` if cp $FILES /cygdrive/r/CopyFile1/$FILES; then echo "copy... (5 Replies)
Discussion started by: CelvinSaran
5 Replies

7. Shell Programming and Scripting

FTP File transfer - Exceptions handling

Hello All, How we can capture the FTP file transfer status. I would like do the exceptions handling for the FTP file transfer My code is something like this... ftp -nvi $FTP_SRVR |& print -p user $UID $PWD print -p cd mydir print -p put $FILE_NAME print -p close print -p bye ... (3 Replies)
Discussion started by: amazon
3 Replies

8. Shell Programming and Scripting

Handling ftp error

I have a script which connects to remote server and ftp the files It works fine, however if there is any failure in ftp connection can it be handled??? ftp log ftp session start time is: Thu Jun 19 00:00:02 BST 2008 Not connected. Not connected. Interactive mode off. Not connected.... (1 Reply)
Discussion started by: vivek_damodaran
1 Replies

9. AIX

Critical error after adding 6 new disks in DS4300

Hello, This morning we have added 6 new disks (73 Gb) to our DS4300, then created a new Array en then created a logical drive, after this was done, teh following error occourd on the last 3 (new)disks: Date/Time: 22-4-08 6:56:26 Sequence number: 5472 Event type: 282D Event category:... (1 Reply)
Discussion started by: topper
1 Replies

10. Programming

CRITICAL 11/08/05 12:06:26 _getsockopt reports error. errno: 239

I am new to this socket programming stuff. I have a problem to fix.. i got the error message. "CRITICAL 11/08/05 12:06:26 _getsockopt reports error. errno: 239" can some please help me with this.. how do i go about fixing this error. thanx in advance.. (0 Replies)
Discussion started by: niks.20
0 Replies
Login or Register to Ask a Question