<div dir="rtl"><div dir="ltr">Thanks for your info, ehud.</div><div dir="ltr"><br></div><div dir="ltr">I found this (<a href="http://www.howtoforge.com/triggering-commands-on-file-or-directory-changes-with-incron">http://www.howtoforge.com/triggering-commands-on-file-or-directory-changes-with-incron</a>) to be much easier to use.</div>
<div dir="ltr"><br></div><div dir="ltr">Thanks,</div><div dir="ltr">Hetz<br><br><div class="gmail_quote">2011/6/14 Ehud Karni <span dir="ltr"><<a href="mailto:ehud@unix.mvs.co.il">ehud@unix.mvs.co.il</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="h5">On Mon, 13 Jun 2011 17:38:26 Hetz Ben Hamo wrote:<br>
><br>
> I'm trying to find a solution to this issue:<br>
><br>
> I'm running an sftp-server in ubuntu. Users can login and upload files.<br>
> What I want to do is to run a script (on the server side) that after user<br>
> logged in and uploaded a file.<br>
><br>
> sftp-server man pages don't give any help about this issue.<br>
<br>
</div></div>The `sftp-server' is a free program, so you can take the source and<br>
fix it any way you want. I wanted to check this so I downloaded the<br>
openssh source tar ball and looked at sftp-server.c .<br>
<br>
I found out that without any change, you can get a log message when<br>
the `sftp-server' close a file, this message include the file name<br>
and the number of bytes read and written. By watching this log you<br>
can do whatever you want after each action.<br>
<br>
Since these are informative messages, You must change the `sftp-server'<br>
logging level to INFO, by adding "-l INFO" arguments to the `Subsystem'<br>
command in the /etc/ssh/sshd_config file.<br>
<br>
If don't want the messages in the SYSLOG, you can add the "-e" argument<br>
and redirect the stderr (i.e ... -l INFO -e 2>>/dir/.../log-file).<br>
<br>
You can use a FIFO file when redirecting so you can read the messages<br>
by a program or script directly. (please note, every time the sftp<br>
session ends, there is an EOF on the reading side, so you must restart<br>
to read).<br>
<br>
I did not check what happens when more then one `sftp-server' is<br>
running, I leave it to you.<br>
<br>
The messages from a short session:<br>
session opened for local user ehud from [192.168.3.6]<br>
open "/var/tmp/chk-ip.sh" flags WRITE,CREATE,TRUNCATE mode 0770<br>
close "/var/tmp/chk-ip.sh" bytes read 0 written 1326<br>
remove name "/var/tmp/chk-ip.sh"<br>
session closed for local user ehud from [192.168.3.6]<br>
<br>
Ehud.<br>
<font color="#888888"><br>
<br>
--<br>
Ehud Karni Tel: +972-3-7966-561 /"\<br>
Mivtach - Simon Fax: +972-3-7976-561 \ / ASCII Ribbon Campaign<br>
Insurance agencies (USA) voice mail and X Against HTML Mail<br>
<a href="http://www.mvs.co.il" target="_blank">http://www.mvs.co.il</a> FAX: 1-815-5509341 / \<br>
GnuPG: 98EA398D <<a href="http://www.keyserver.net/" target="_blank">http://www.keyserver.net/</a>> Better Safe Than Sorry<br>
</font></blockquote></div></div><br clear="all"><br>-- <br><div dir="rtl"><div style="color:rgb(0, 0, 0);font-family:Verdana, Arial, Helvetica, sans-serif;margin-top:8px;margin-right:8px;margin-bottom:8px;margin-left:8px;background-color:rgb(255, 255, 255)">
<p dir="rtl"><strong style="font-size:10px"><span style="font-size:small"><span style="color:rgb(0, 0, 128)"><span style="color:rgb(0, 0, 0);font-weight:normal">חץ בן חמו</span><br>ח</span><span style="color:rgb(0, 0, 255)">ץ</span>-<span style="color:rgb(0, 0, 128)">ב</span><span style="color:rgb(0, 0, 255)">י</span><span style="color:rgb(51, 102, 255)">ז</span><br>
</span></strong>השכרה ואירוח של שרתים פיזיים<br>מעוניין להשתמש בשרותים שחסומים לגולש הישראלי? Hulu? NetFlix? Pandora? Google Voice? אם כן, כנס <a href="http://vps.net.bz/?p=406" target="_blank">לכאן</a>.</p></div></div><br>
</div>