[geeks] ftp upload renaming

Mike F lists at ibrew.net
Sat Sep 16 11:53:14 CDT 2006


On Sep 14, 2006, at 10:25 PM, Charles Shannon Hendrix wrote:

> I have a client who wants users to be able to stage new documents to a
> UNIX server that processes documents.  The processing involves moving
> a document into the right place, reading it and putting parts of it  
> in a
> database, etc.
>
> The user's will not have direct access to this machine: they can only
> upload files to it.
>
> The client doesn't want the users to be able to upload any filename  
> they
> choose, and some I'm looking for a way to have the ftp server take
> whatever file they upload and give it a uniform name.  Something  
> simple
> like a sequence will be fine.  In other words:
>
> 	file0001
> 	file0002
> 	file0003
> 	file0004
>
> It doesn't matter because the files will be processed, put in a
> database, and a copy renamed in a structured hiearchy by the
> system anyway.
>
> Mainly I just need to avoid user stupidity in the names.
>
> Is there any kind of ftp server that has "upload hooks" to handle  
> things
> like this?

Take a look at Pure-FTPD. Here's the relevant snippet of the  
configuration process:

--with-uploadscript: since 0.98, Pure-FTPd has a nice feature regarding
uploads. Any external program or script can be automatically called  
after a
successful upload. It needs another program installed by the Pure-FTPd
package, called 'pure-uploadscript'. Check the man page for more info  
about
this.

 From pure-uploadscript(8):

NAME

pure-uploadscript - Automatically run an external program after a  
successful upload

SYNTAX

pure-uploadscript [-p </path/to/pidfile>] [-B] [-g <gid>] [-h] -r  
<program to run> [-u <uid>]

DESCRIPTION

If Pure-FTPd is compiled with --with-uploadscript (default in binary  
distributions), and if the -o (or --uploadscript) is passed to the  
server, a named pipe called /var/run/pure-ftpd.upload.pipe is  
created. You will also notice an important file called /var/run/pure- 
ftpd.upload.lock, used for locking. After a successful upload, the  
file name is written to the pipe. pure-uploadscript reads this pipe  
to automatically run any program or script to process the newly  
uploaded file.

- Mike



More information about the geeks mailing list