running script after sftp upload

running script after sftp upload

Hetz Ben Hamo hetzbh at gmail.com
Tue Jun 14 23:34:39 IDT 2011


Thanks for your info, ehud.

I found this (
http://www.howtoforge.com/triggering-commands-on-file-or-directory-changes-with-incron)
to be much easier to use.

Thanks,
Hetz

2011/6/14 Ehud Karni <ehud at unix.mvs.co.il>

> On Mon, 13 Jun 2011 17:38:26 Hetz Ben Hamo wrote:
> >
> > I'm trying to find a solution to this issue:
> >
> > I'm running an sftp-server in ubuntu. Users can login and upload files.
> > What I want to do is to run a script (on the server side) that after user
> > logged in and uploaded a file.
> >
> > sftp-server man pages don't give any help about this issue.
>
> The `sftp-server' is a free program, so you can take the source and
> fix it any way you want.  I wanted to check this so I downloaded the
> openssh source tar ball and looked at sftp-server.c .
>
> I found out that without any change, you can get a log message when
> the `sftp-server' close a file, this message include the file name
> and the number of bytes read and written.  By watching this log you
> can do whatever you want after each action.
>
> Since these are informative messages, You must change the `sftp-server'
> logging level to INFO, by adding "-l INFO" arguments to the `Subsystem'
> command in the /etc/ssh/sshd_config file.
>
> If don't want the messages in the SYSLOG, you can add the "-e" argument
> and redirect the stderr (i.e ... -l INFO -e 2>>/dir/.../log-file).
>
> You can use a FIFO file when redirecting so you can read the messages
> by a program or script directly. (please note, every time the sftp
> session ends, there is an EOF on the reading side, so you must restart
> to read).
>
> I did not check what happens when more then one `sftp-server' is
> running, I leave it to you.
>
> The messages from a short session:
>    session opened for local user ehud from [192.168.3.6]
>    open "/var/tmp/chk-ip.sh" flags WRITE,CREATE,TRUNCATE mode 0770
>    close "/var/tmp/chk-ip.sh" bytes read 0 written 1326
>    remove name "/var/tmp/chk-ip.sh"
>    session closed for local user ehud from [192.168.3.6]
>
> Ehud.
>
>
> --
>  Ehud Karni           Tel: +972-3-7966-561  /"\
>  Mivtach - Simon      Fax: +972-3-7976-561  \ /  ASCII Ribbon Campaign
>  Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
>  http://www.mvs.co.il  FAX:  1-815-5509341  / \
>  GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry
>


-- 

*חץ בן חמו
חץ-ביז
*השכרה ואירוח של שרתים פיזיים
מעוניין להשתמש בשרותים שחסומים לגולש הישראלי? Hulu? NetFlix? Pandora? Google
Voice? אם כן, כנס לכאן <http://vps.net.bz/?p=406>.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20110614/c6fb0ab4/attachment.html>


More information about the Linux-il mailing list