Douglas Muth on 20 Apr 2010 13:12:54 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Advice needed on collecting files from FTP site

On Tue, Apr 20, 2010 at 3:38 PM, Mike Leone <> wrote:
> So here's my situation - I have a Linux server set up in a DMZ, running
> VSFTP. Each FTP account is chrooted. We will be using this for vendors
> to send us invoices, etc.
> The FTPing part is working fine. The chrooting is working fine. What I
> need to do now, is to have a method of sweeping through all these home
> folders; collect any new files; zip them all together; and FTP them
> inbound to the trusted part of my LAN. And then delete the file, once
> it's been FTPed in.

With the possible exception of FTP (not sure if it can really be
scripted), this is fairly straightforward in shell script:


# Find files newer than our timestamp file
FILES=`find /path/to/ftproot/ -anewer /var/run/timestamp`

# Note our new timestamp for the next run.
# There is an race condition here that I could probably solve given more time.
touch /var/run/timestamp

# Put them into a temp file

# Copy them to our target server via scp
# Give the zipfile a unique name, based on the current timestamp.
DATE=`date +%Y%m%d%H%M%S`
scp $TARGET user@host:files_${DATE}.zip

# The End.

Note that you really want to use ssh/scp instead of FTP.  It's much
easier to script, for one.

-- Doug
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --