How to determine whether the FTP was successful or not


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to determine whether the FTP was successful or not
# 1  
Old 10-23-2009
How to determine whether the FTP was successful or not

Hi,

In a shell script we issue a ftp command to transfer some files, so the shell script process invokes another FTP Process. The ftp session has started but due to some reason the ftp is broken, then how to determine in the script that the file transfer was not successful.
We can make a check after issuing the ftp command like this :

Code:
ftp bla bla
if [ $? -ne 0 ]; then
  echo "File transfer was not successful"
fi

The check for exit status cannot determine whether the file has reached the destination or not. How to determine this in the script.
Can any1 please suggest me how do I go about this?

Thanks

Last edited by zaxxon; 10-23-2009 at 03:20 AM.. Reason: code tags
# 2  
Old 10-23-2009
Have a look here:
https://www.unix.com/shell-programmin...-succeeds.html

*********************************************************************************

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
# 3  
Old 10-23-2009
Quote:
Originally Posted by julie_s
Hi,

In a shell script we issue a ftp command to transfer some files, so the shell script process invokes another FTP Process. The ftp session has started but due to some reason the ftp is broken, then how to determine in the script that the file transfer was not successful.
We can make a check after issuing the ftp command like this :

Code:
ftp bla bla
if [ $? -ne 0 ]; then
  echo "File transfer was not successful"
fi

The check for exit status cannot determine whether the file has reached the destination or not. How to determine this in the script.
Can any1 please suggest me how do I go about this?

The ftp command is intended for interactive use, and it doesn't work well in scripts.

For scripting, use the ncftp family of commands.

(Or, if possible, use ssh and scp.)
# 4  
Old 10-23-2009
Also have a look at lftp. It supports scripting of ftp, sftp and more.
# 5  
Old 10-23-2009
Save the ftp session in a log file, then look for feedback like
"Transfer complete" or "File receive OK"
# 6  
Old 10-29-2009
How to determine whether the FTP was successful or not

Thanks alot..I am using AIX machine and there is no sftp and ncftp commands. There is only ftp command.
My questin is when we issue an ftp command from a shell script, the ftp command executes as a different process. Will the shell script keep track of the exit status of some other process.

Is there any sftp package available for AIX?

--
Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ftp - file transfer and check successful delivery

In shell script, I want to transfer files continuously and make sure transfer is successful. Please advise... how to make sure ftp transfer is successful? Also is there any option such as sftp -b where I can pass multiple put <file name> commands to ftp Thanks! (1 Reply)
Discussion started by: vegasluxor
1 Replies

2. Shell Programming and Scripting

FTP Status check(whether it is successful or not)

Hi Friends I need to check the status of FTP connection i.e. Whether it is successful or not I have tried this by assigning the FTP connection script to a variable and after that using this variable I tried to check the status. In the below code snippet I am trying to assign the FTP... (1 Reply)
Discussion started by: Kannannair
1 Replies

3. UNIX for Advanced & Expert Users

Wether does it successful or unreachable?

Hi, all: How can I check what happen with my own NIC driver which response "successful" when local PC "ping" a remote linux PC but "unreachable" when it "ping" a remote windows XP PC? My writed driver runs in linux 3.0.4 kernel. thanks! li, kunlun (1 Reply)
Discussion started by: liklstar
1 Replies

4. Solaris

How to view only successful login?

Hi all, I have to view only success full login attempts . View who are all logged in correctly , and where it can be stored? Thanks in advance Gnanavel (3 Replies)
Discussion started by: Gnanavel
3 Replies

5. UNIX for Dummies Questions & Answers

How to get successful/unsuccessful FTP logs in UNIX

Hi, We have one UNIX Server (Sun Solaris), and the files coming to this server from another server. The problem is, that server is continously sending files to our server via FTP. But the observation is that some files missing in our Server but in that server it shows the files FTPed... (2 Replies)
Discussion started by: vikash.rastogi
2 Replies

6. UNIX for Dummies Questions & Answers

Test if execution was successful

Hi How can I test inside a shel script whether the last action was successful or not. I have the following line which is executing inside a script . ./runProcess.sh $i $var_num>> error.txt 2>&1 This is occuring in a loop. How can i test whether it was succes for last var_num or not. How... (2 Replies)
Discussion started by: Prashantckc
2 Replies

7. Shell Programming and Scripting

Detemine if SED is successful

Is there a way of finding out if an issued sed command is successful? Basically, in my script I have a command where mydata=$(cat record | sed '...command here...'). When the sed command finds the data that I am after it is assigned to mydata. When the sed command does not find the data I am... (1 Reply)
Discussion started by: gugs
1 Replies

8. Shell Programming and Scripting

ftp - determine ascii or binary file

Hello, How to i determine via ftp commandline if files on ftp server is ascii or binary files. Like every other comon windows ftp program does it automatically. regards Thomas (5 Replies)
Discussion started by: congo
5 Replies

9. UNIX for Dummies Questions & Answers

Successful Installion of Apache

I finally finished installing Apache on my companies SCO server. The problem was with the way I uncompressed the Apache .tar.z file. I downloaded Apache onto a windows computer on our network. Then I used winzip to uncompress the files. After un- compressing the files, I transferred them to the... (0 Replies)
Discussion started by: cstovall
0 Replies
Login or Register to Ask a Question

Featured Tech Videos