Solved

Check whether FTP is successful or not, in a Unix shell script

Posted on 2004-08-21
7
1,890 Views
Last Modified: 2013-12-26
I want to write a Unix shell script which will ftp a file from one server to another.  I want to check whether the FTP is successful or not.  After the FTP is complete, I would like to check the cksum of local and remote file, to compare whether the transfer was successful.  I dont want to use ssh.  How can I do this?

Also, if I can print the status of each of the statements below, then it would be great.

ftp username password
<check whether you are able to login, or is there a failure>
lcd /home/abcd
<check whether this folder exists>
cd /home/efgh
<check whether this folder exists>
put a_local.txt  a_remote.txt
<check the status here, whether file was completely or partially transferred>
0
Comment
Question by:paragpjoshi
7 Comments
 

Author Comment

by:paragpjoshi
ID: 11863543
Someone please help ASAP
0
 
LVL 5

Accepted Solution

by:
ITcrow earned 500 total points
ID: 11865819
#!/bin/sh

{ echo "
open ftp.someserver.wherever
user anonymous anonymous@mars.nodomain
hash
lcd /home/abcd
pwd
cd /home/efgh
pwd
put a_local.txt  a_remote.txt
close
"
} | ftp -inv 2>&1 | tee ftp_session.log

Go ahead, add any kind of commands in it, which you normally use in
interactive FTP.

In addition you are getting a complete session log "ftp_session.log"
0
 
LVL 2

Expert Comment

by:rajeshp_69
ID: 12074048
It'll be highly impossible to interpret the ftp session and check the conditions. If you want to achieve the same try with rsh or remsh commands. Check the man pages and you can achieve the same. If you need any help regarding rsh/remsh then let me know.

Bye
0
 

Expert Comment

by:lb2020
ID: 33162897
Hi folks,
 I have the same requirement i need to trap the errors in FTP transfer using unix .Iam new to unix please help me out if u have any sample code regarding this.

I also need to check whether ftp successful or not..

Thanks,
Lenin

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bigDiff challenge 17 85
centeredAverage challenge 8 132
java ^ examples 8 62
haveThree challenge 22 114
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now