Scripting with FTP Process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting with FTP Process
# 1  
Old 05-03-2012
Scripting with FTP Process

Hi Guys,

Good day ULF! I have a general "auto-ftp" code which looks something like this:

Code:
#!/bin/sh

cd $1
ftp -v -n $2 << EOF
user $3 $4
prompt
cd $5
bin
mput $6
quit
EOF

This works pretty well, but I'm thinking of how can I make a code by maybe including on this code, for example checking or comparing the filesize that has been transferred from the one that has been received on a particular remote server, and if so happen that the received file has a size of 0 bytes, it will retry and send the file until the received file is exactly same size with the transferred file.

Say for example (mput $6) then $6 has a size of 1000 bytes, then I want that when the received file was 0 bytes, I want the code to retry it.

Is this possible? Yah I know that it's pretty much to include ls -lrt, then after execution by manually checking it, but the process will be put in CRON so that it will be somewhat automated.


Please advise!


BR,
rymnd_12345
# 2  
Old 05-03-2012
Please mention the Operating System and version of both computers concerned and something about the type of file being transferred.
Do you have remote Shell and interactive Shell access to both computers?
# 3  
Old 05-03-2012
Hi methyl,

- Both servers are working on a Linux OS.
-Type of file is a created file (run by another script) under the source server. Maybe some kind of file containing a list of lines only.
- Yes, remote and interactive shell are both present on both servers.


BR,
rymnd_12345
# 4  
Old 05-03-2012
Any reason you are using ftp rather (than say scp or rcp) ?
# 5  
Old 05-03-2012
Hi methyl,

Haven't tried yet before, but I've tried to use this command below:

Code:
scp FILE user@<IP>:/home/output/

then of course it prompted for a password, followed by successful secure copy of file to the other server.

Code:
Password:
FILE                                                                                                                           100% 1456     1.4KB/s   00:00

Problem here I think is that on the automation part since I want to put it on CRON, and this will require an expect scripting (guess so?).

Please advise on how can I improve my code like I want to make sure that the file has been transferred/copied to the other server automatically.


BR,
rymnd_12345
# 6  
Old 05-03-2012
Here is a pretty good worked example of setting up scp without password:

Pass on Passwords with scp | Linux Journal
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting errors for ftp process

Hi i am facing problem in shell scripting for ftp process getting following errors here is the script & result vi GtpTxnlogs_ftp.sh "GtpTxnlogs_ftp.sh" 40 lines, 921 characters #!/usr/bin/bash ###################################################################################### #... (4 Replies)
Discussion started by: Sarmistha
4 Replies

2. UNIX for Dummies Questions & Answers

FTP scripting issue

I dont have enough bits to post in emergency, but I have an urgent FTP issue. A client of ours wants us to pull files from his server onto our server at which point we can process it. I ask a friend what to do, but I was just give the things to do, not how to do it. I havent written a Unix... (4 Replies)
Discussion started by: MJCreations
4 Replies

3. Shell Programming and Scripting

Need FTP scripting

Hi, Please can you tell me the script to transfer file from server A to Server B (1 Reply)
Discussion started by: e1994264
1 Replies

4. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

5. Shell Programming and Scripting

FTP scripting Help

Hi, I'm trying to do an FTP script that will read from a list of files and send only the files in that list. Would this work? Does anyone have anything simpler. ftp -nv <<EOF open server user username password get $(nawk -F_ -f bbb.awk Filelisting.txt) EOF (5 Replies)
Discussion started by: bbbngowc
5 Replies

6. Shell Programming and Scripting

FTP-Shell scripting

Hi Everybody, I have come across a problem while doing FTP using shell scripting. So I request any of you can give some idea of how to go about solving the problem but i request you not to give the solution please. Because i'm a java developer newly into Unix shell progrmming and am very enthu... (1 Reply)
Discussion started by: RSC1985
1 Replies

7. Shell Programming and Scripting

FTP scripting

Hello, I'm sure this is an easy one for you UNIX pros. I would like to create and and automated an FTP process. The script should do this: 1. Log into a remote system 2. change to a specified directory 3. copy local files to the remote system 4. quit ftp 5. wait until the next schedule ... (7 Replies)
Discussion started by: bbbngowc
7 Replies

8. Shell Programming and Scripting

Error in scripting ftp

Good Morning, I just would like to know what is wrong with my script. I am trying to use a for loop on my ftp command but the part that pipes the ftp information is reported in unix as error. Here's my script : #!/bin/ksh # other parts of the script here.... # get all ORD* files... (10 Replies)
Discussion started by: negixx
10 Replies

9. Answers to Frequently Asked Questions

Automate FTP / Scripting FTP Transfers

One of our most frequent questions is how to automate ftp transfers. There are several approaches. Since I'm writing this post, we will start with my favorite technique. :) In Automated FTP task I present a simple example of my ksh co-process technique. And note that later in this thread I... (0 Replies)
Discussion started by: Perderabo
0 Replies

10. Shell Programming and Scripting

scripting a ftp process

I am trying to automate a process in one of two ways: 1) ftp .txt files from a unix server to a Windows 2000 server. I want to do this in a script. Can I supply the login and password to the Windows server inside the script? 2) I tried this and failed: sftp .txt files from the unix server to... (2 Replies)
Discussion started by: gbernard
2 Replies
Login or Register to Ask a Question