?
Solved

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

Posted on 2004-08-21
7
Medium Priority
?
2,162 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
4 Comments
 

Author Comment

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

Accepted Solution

by:
ITcrow earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

755 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