![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Terminal And Cron Job Return Different Status Code | isaac_ho | Shell Programming and Scripting | 1 | 06-02-2008 12:12 AM |
| Return of EXIT status ( $? ) | ZINGARO | HP-UX | 1 | 03-12-2008 07:07 AM |
| Verify scp return status | new2ss | Shell Programming and Scripting | 2 | 06-28-2006 10:04 PM |
| Return status of all previous runs | mpang_ | Shell Programming and Scripting | 4 | 06-27-2006 02:58 AM |
| Return status... | Shaz | Shell Programming and Scripting | 7 | 11-19-2002 06:35 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello,
I still have problems when trying to figure out if the status of an ftp was successful. I ftp to different types (nt, vax, unix, etc...) of machines. I am trying to write a universal script that will ftp a file and then check to see if the ftp was successful. I have tried the following: verify file sizes: VAX and UNIX boxes have different file sizes grep ftp result for: code 226; some boxes have different sayings Do you have ideas? Thanks, Barbara |
|
|||||
|
In this post, I show the best technique that I have found to get the return codes. It is imperfect, and I'd love to see a better idea. Because it's so hard to know how long to sleep, I usually take my best shot, then double it. This technique wastes a lot of clock time.
Yeah, there are several codes that can result from an operation failing. You will need to check for them all. But it's not like every programmer can make up his own codes or anything. The codes are documented in RFC 959. Any ftp server that returns different codes is broken. For transfers, I would just look for the presense of a code 226. That would indicate that the transfer worked. No code 226, it must've failed. But if you want to diagnose the error, this won't be enough. It depends on how far you want to go. Also, I don't understand why your file sizes are off. This sounds like you did an ascii transfer when you needed a binary transfer. |
|
||||
|
Hope this can help
ftp -v hostname -v that will show all responses from the remote server, as well as report on data transfer statistics. This is turned on by default if ftp is running interactively with its input coming from the user's terminal. |
|
||||
|
Thanks!
In the past, I have checked for "226". There have been some cases where the bytes transferred, bytes sent, or transfer time contains "226". The job result is successful, yet the ftp was not successful. So this doesn't always work for my scenario. The translation of code 226 is not consistent on all boxes. For example, I have seen "226 Closing data connection" or "226 Transfer Complete" as a translation for code 226. I do have -v in my ftp command line. Because the "226" code is not consistent, the status returned is not always reliable. Thanks, Barbara |
|
||||
|
Thanks.
I'm sorry I guess I didn't explain myself correctly. This is my existing code: ftpresults=`ftp -inv $ip_box_name <<EOB user $userid $password put $ftp_file $downstream_name bye EOB` ftp_ctr=`echo "$ftpresults" | grep "226 Transfer complete" | wc -l` echo $ftp_ctr if [ $ftp_ctr = 1 ] then echo "FTP of " $file_name " to " $ip_box_name " was successful" echo " " else ftp_error="true" fi In my prior reply, I was trying to say that if I did a grep on "226" alone, a count of 1 would be returned if the bytes transferred were a size which contained "226". I am trying to find something in the return of the ftp to grep. This will allow me to tell me if it was successful. I read the codes that you had passed along in your prior response. Thanks, Barbara |
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|