Visit Our UNIX and Linux User Community

Script for FTP (transfer only new files)

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for FTP (transfer only new files)
# 1  
Old 10-31-2008
Script for FTP (transfer only new files)

Hi everybody,

I just want to transfer files with FTP (mget and mput). The problem is that I dont want to overwrite any existing files and don't want to transfer them again (e.g. using the rename-function). So I only want to transfer new files with mget and mput.

My first idea was to create two listings (remote and local) and compare them, maybe with diff.

Here is my actual code:
#! /bin/sh

ls /testdir > /local/local-list.txt

ftp -i -n ftp-server <<END_SCRIPT
quote USER $USER
nlist /testdir /local/remote-list.txt

diff ??? ??? > /local/new_files.txt

ftp -i -n ftp-server <<END_SCRIPT
quote USER $USER
mget ???

I need two more steps:
1. Create a usable list with all new files listed on the ftp server
2. Turn this list over to mget and transfer all listed

I hope anybody can help me. I'm very frustrated now. Smilie

Best regards from germany.
# 2  
Old 10-31-2008
Why not use rdist? [man rdist(1)]
rdist - remote file distribution program can do exactly what you want...
# 3  
Old 10-31-2008
@vbe: Thank you for your reply. I don't know rdist - I will check this. But the server I'm connecting to (over internet) is not ours, and there is only ftp permitted. So I think I could not use rdist. Correct me if I'm wrong.
# 4  
Old 11-14-2008
I'll checked rdist, but this was not the right tool for me.

First I tried it with the enhanced ftp-client tnftp, formerly known as lukemftp (link). But I also had some troubles with the overwrite-protection.

I found another solution: wput (link). There you can set an option, so that no files will re-loaded again. But this works only with version 0.6.2 for me.

Here is my actually code:
#! /bin/sh

wget ftp://$HOST/DIR01/* -nc --ftp-user=$USER --ftp-password=$PASSWD
wput --disable-tls --basename=$LOCAL_FILES/ $LOCAL_FILES/* ftp://$USER:$PASSWD@$HOST/DIR02/

It works great.

Previous Thread | Next Thread
Test Your Knowledge in Computers #594
Difficulty: Easy
In the C programming language, variables are scoped to the code block in which they are declared and are only valid within that code block.
True or False?

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. Shell Programming and Scripting

Transfer multiple different files in FTP

Hi All, i am doing ftp how can i transfer multiple different files example- 03-21-13 06:33AM 46800 CATT_HOURS.pgp 03-21-13 06:33AM 266392 CATT_TAX.txt 03-21-13 06:33AM 91448 CATT_STATUS.txt 03-21-13 06:33AM 468 ... (3 Replies)
Discussion started by: krupasindhu18
3 Replies

3. IP Networking

How to transfer files from UNIX server to windows machine or vice versa using ftp or sftp commands?

hi, i want to write a shell script code which transfers files from a directory in unix server to a directory in a windows machine.. can any1 give me a sample code which uses ftp or sftp command.. thanks very much, (3 Replies)
Discussion started by: Little
3 Replies

4. Shell Programming and Scripting

Transfer files from linux server to windows using secure ftp (sftp)

HI, I have to transfer files from linux server to windows using secure ftp (sftp) .Kindly help me out. (3 Replies)
Discussion started by: manushi88
3 Replies

5. Shell Programming and Scripting

RSYNC script to transfer folders recursively without overwriting via FTP

Hi all, I would need a bash script to sync/transfer folders recursively via FTP/RSYNC (I initially planned to use FTP but I heard RSYNC would fit a lot better for this job(?)) The situation: 3 different Linux servers 1. source 2. destination - Samba 3. Server where the script runs on ... (2 Replies)
Discussion started by: thibautp
2 Replies

6. Shell Programming and Scripting

Help needed to transfer list of files to FTP server, to different folders

Hello Unix Gurus, Help required from you. My requirement is something like this I want to create a concurrenct program in Oracle Applications using shell script to transfer files from Apps Server to destination FTP server. I have created custom program, where I will extract all the... (4 Replies)
Discussion started by: amazon
4 Replies

7. Shell Programming and Scripting

FTP run from shell script gives slow transfer rates

Hey everybody, this is my first post so be gentle. I have two Sun 5220's running Solaris 10 that are directly connected with a cross-over cable at Gig. One of these boxes is my production Oracle server which generates a 50GB dump file every evening at 10:50. The other Solaris is a devolopment... (8 Replies)
Discussion started by: Countificus
8 Replies

8. UNIX for Advanced & Expert Users

script to be run after every FTP transfer

Hello everyone, we are running VSFtpd as FTP Server on Redhat AS 5. I would like to have a script to be run immediately after every FTP transfer. Is is possible (or with any other FTP Server?). I thought of writing a script to monitor if FTP transfer happening and run the required-script... (2 Replies)
Discussion started by: prvnrk
2 Replies

9. UNIX for Dummies Questions & Answers

Transfer files from Unix server to Windows using FTP

Dear Friend, I don't know much about unix.I am an VB6.0 Programmer.I need to move an text files as aaa.txt from unix server to windows "D: " driver using the FTP protocol.Is it possible to do this with help of unix shell script.If possible please give some sample codes. Please answer as early... (1 Reply)
Discussion started by: gjsaravanan
1 Replies

10. Shell Programming and Scripting

transfer of files via ftp from windows to unix

I am currently looking to write a script to transfer files from a windows NT server to a unix server any ideas of how to go about this? (1 Reply)
Discussion started by: chambala5
1 Replies

Featured Tech Videos