Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-08-21
7
Medium Priority
?
2,140 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 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