Status check of Automated FTP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Status check of Automated FTP
# 1  
Old 03-03-2004
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

TMP_FILE=/tmp/$$-FTP
echo " open <hostname>" > ${CMD_FILE}
echo "user <user name> <password> " >> ${CMD_FILE}
echo "put <some file> " >> ${CMD_FILE}
echo "bye" >> ${CMD_FILE}

ftp -vin < ${CMD_FILE} 1> /dev/null 2>>${ERROR_LOG}

if [ $? -ne 0 ]; then
echo "\nError Transmitting the file"
rm -f ${CMD_FILE}
exit 1
else
echo "\nSuccessfully Transmitted report file."
fi

rm -f ${CMD_FILE}

}

The problem with above function is that even though the actual put command is not successful, say because file system is full or lack of appropriate permission, script will always report that file was transmitted successfully.

This is because last command "bye" executed as a part of FTP is always successful & "$?" always returns 0.

Any pointers how can I check whether "put" command was successful or not?

P.S. :- Requirement is not to log output of ftp command in ERROR_LOG. It has to be discarded, no matter whether FTP is successful or not.






}
# 2  
Old 03-03-2004
You probably should do a second ftp but this time
list the relevant directory to a logfile. Then exit
ftp and grep for the specific file that was 'put'
in the logfile.
# 3  
Old 03-03-2004
.....

Last edited by druuna; 05-21-2009 at 10:15 AM..
druuna
# 4  
Old 03-04-2004
Would it not be better to do a checksum before you put <file>,
then send the checksum file with original file. Once original file
arrives with checksum file, do verification on checksums.

Is this not 100% effective in a precise automated system?
# 5  
Old 03-04-2004
The checksum idea requires the recipient to do the checking. I think that the OP want a way for the sender to verify that the file arrived without help from the recipient.
# 6  
Old 03-04-2004
Why not capture the output from ftp and grep for success?

ftp -vin < ${CMD_FILE} 1> ${FTP_LOG} 2>&1
grep -q 'Transfer complete' ${FTP_LOG}
if [ $? -ne 0 ]
then
echo error
fi
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. 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

4. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

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

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

7. Shell Programming and Scripting

automated ftp.

Hi I am trying to delete some specific files ( files other than created today) from the server on a cron basis. I wrote a small script, but I am stuck up in how to delete only specific files. #!/usr/bin/expect -f set IP set timeout -1 spawn ftp $IP expect ): send "username\n"... (10 Replies)
Discussion started by: sangfroid
10 Replies

8. UNIX for Dummies Questions & Answers

Automated FTP to variable directory with error check

Hi, automated FTP that have error check and each product FTP will used the same userid/password to post(transfer) the file(s) from their <product> directory at UNIX to their <product> folder at Windows. such senarios as follows: NOTE: ======= ** Variable ** * The <product> is variable... (3 Replies)
Discussion started by: songtam
3 Replies

9. Shell Programming and Scripting

check the status and send an email with status

Hi, We have a text file which has the following data. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002 ST~997~0001 AK1~SH~247 AK2~856~2470001 AK5~A AK2~856~2470002 AK5~A... (3 Replies)
Discussion started by: isingh786
3 Replies

10. 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
Login or Register to Ask a Question