FTP Status check(whether it is successful or not)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP Status check(whether it is successful or not)
# 1  
Old 04-22-2013
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 conenction status to a variable.

Code:
 
STATUS=`ftp -n $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
prompt off
cd /user/sba-appl/test/sscr/ramu/
lcd /user/sba-appl/productie/sscr/darshan
mget  get.DAT
bye
EOF`

Can anyone tell whether this approach is correct or not. When i am trying this method FTP connection is not happening. Whether we can assign the FTP connection like this

Because after this i can use the above variable and check the status for various FTP states like 226 553etc using the grep command.

Thanks and Regards
Darshan
# 2  
Old 04-22-2013
Different clients return different $? values; most return 0 regardless of the result of the FTP operation.

As you already pointed out, you can store the full output in $STATUS by using verbose flag, then look up for a successful FTP code (225 for successful data connection or 226 for successful file transfer). Something like:
Code:
STATUS=`ftp -nv $HOST <<EOF
<...ftp commands...>
EOF

if [ "$(echo $STATUS | grep -c 226)" -ge 1 ]; then echo "Success"; fi

Of course this assumes you aren't transfering a file with "226" as part of its name.

Keep in mind that FTP code 226 can also show up when you manually abort a transfer that is already in progress. Not sure if this is an issue for your process.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to see the status of all the ftp put & get files logs and curent ftp transfer status ?

How to see the status of all the ftp put & get files logs and curent ftp transfer status if any active ftp running in the background ? (2 Replies)
Discussion started by: i4ismail
2 Replies

2. UNIX for Advanced & Expert Users

FTP commands to check the file status

Hi Experts, Can some one let me know the FTP commands to check the file status i.e i want to check whether my files are locked or in open status. I am connecting FTP from local machine. Regards, Spidy (1 Reply)
Discussion started by: spidy
1 Replies

3. UNIX for Beginners Questions & Answers

Automation script for email alert when a job get complete with status successful.

Guyz, Please let me know about script which is to be sending an automatic email to particular mail id's when a monotoring job get complete with status successful. (1 Reply)
Discussion started by: Rehan Ahmad
1 Replies

4. Shell Programming and Scripting

How to check the status of sftp connection is successful or not in Linux?

Hi All, We are working on linux with putty terminal for file transferring using SFTP server... here we want to know /We have Urgent Requirement If SFTP connection is successfull then we should get .txt log file in target locaton as "Success/Failure" Please provide batch script for above... (7 Replies)
Discussion started by: sravanreddy
7 Replies

5. 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

6. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: julie_s
5 Replies

7. Shell Programming and Scripting

Check FTP Status

To all, I need to run a ftp command in one of my scripts and I need to evaluate what happens after it's done. The problem is the script would not capture the ftp responses. If I type the same thing on the command line, I get all kinds of responses. I would like to capture the same responses in... (2 Replies)
Discussion started by: april
2 Replies

8. Shell Programming and Scripting

How to check the FTP Status?

Hi, I wrote a script that is generating a file and then i have to ftp this file on another server. For this i am using mput to put the file. How can i make sure that the file was ftp'd correctly to the another server, is there any status check ? Thanks. (1 Reply)
Discussion started by: smc3
1 Replies

9. Shell Programming and Scripting

Ftp Status Check

Hi, I'm using the below script to ftp the file passed as 3rd argument. I'm passing the source and destination directory as 1st and 2nd argument. This script does the ftp successfully. The script displays the echo before ftp stmt and does the ftp and does not display the stmts after that... (4 Replies)
Discussion started by: acheepi
4 Replies

10. Shell Programming and Scripting

Status check of Automated FTP

Hi, I've following code fragment as a part of 1 of my scripts. Function is supposed to perform automated ftp to designated host. Here are the details:- #! /usr/bin/ksh < some code> perform_ftp() { #Assume that file to transfer is available in current directory ... (5 Replies)
Discussion started by: anijog
5 Replies
Login or Register to Ask a Question