Re: running script after sftp upload

2011-06-14 Thread Hetz Ben Hamo
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 

> 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>.
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: running script after sftp upload

2011-06-14 Thread Ehud Karni
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

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: running script after sftp upload

2011-06-14 Thread Hetz Ben Hamo
What I meant was simple:

Lets say you have a sftp-server, which various people upload your files to
it.
After a file has been upload it, a script would automatically launch to
parse the file, change it's permissions, move it etc.

At the end the solution was to use incron.

Thanks,
Hetz

2011/6/14 Raz 

> though I am not sure this is what hetz meant , i would have done it as
> follows:
> if some new file opened in /ftpdir
>   then run lsof -p  | grep filename
>   if true then ftp downloaded it
>
> what say you ?
>
> On Tue, Jun 14, 2011 at 11:13 AM, Elazar Leibovich wrote:
>
>>
>>  On Tue, Jun 14, 2011 at 10:49 AM, Raz  wrote:
>>
>>>  so the file has an owner. the script should query the owner id. am i
>>> missing something here ?
>>>
>>
>> How would he know if the owner used ftp, or didn't use ftp?
>>
>>
>
> ___
> Linux-il mailing list
> Linux-il@cs.huji.ac.il
> http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
>
>


-- 

*חץ בן חמו
חץ-ביז
*השכרה ואירוח של שרתים פיזיים
מעוניין להשתמש בשרותים שחסומים לגולש הישראלי? Hulu? NetFlix? Pandora? Google
Voice? אם כן, כנס לכאן <http://vps.net.bz/?p=406>.
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: running script after sftp upload

2011-06-14 Thread Raz
though I am not sure this is what hetz meant , i would have done it as
follows:
if some new file opened in /ftpdir
  then run lsof -p  | grep filename
  if true then ftp downloaded it

what say you ?

On Tue, Jun 14, 2011 at 11:13 AM, Elazar Leibovich wrote:

>
>  On Tue, Jun 14, 2011 at 10:49 AM, Raz  wrote:
>
>>  so the file has an owner. the script should query the owner id. am i
>> missing something here ?
>>
>
> How would he know if the owner used ftp, or didn't use ftp?
>
>
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: running script after sftp upload

2011-06-14 Thread Raz
On Mon, Jun 13, 2011 at 6:10 PM, Elazar Leibovich  wrote:

> 2011/6/13 Raz :
> > set up inotifier on the upload library.
>
> How would you know who copied the file to this library?
>
it is not a requirement as  i understand.
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: running script after sftp upload

2011-06-13 Thread Elazar Leibovich
2011/6/13 Raz :
> set up inotifier on the upload library.

How would you know who copied the file to this library?

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: running script after sftp upload

2011-06-13 Thread Raz
set up inotifier on the upload library.

2011/6/13 Hetz Ben Hamo 

>  Hi,
>
> 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.
>
> Any suggestions?
>
> Thanks,
> Hetz
>
> ___
> Linux-il mailing list
> Linux-il@cs.huji.ac.il
> http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
>
>
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


running script after sftp upload

2011-06-13 Thread Hetz Ben Hamo
Hi,

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.

Any suggestions?

Thanks,
Hetz
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


sftp

2002-02-01 Thread Behdad Esfahbod


Try ssh client from http://www.ssh.com/

Has a nice sftp client, and free license for educational, charity and
personal recreational/hobby use.


-- 
Behdad Esfahbod 12 Bahman 1380, 2002 Feb 1 
  [Finger for Geek Code]

John Coffey...you have been
condemned to die in the electric
chair by a jury of your
peers...sentence imposed by a
judge in good standing in this
state. Do you have anything to say
before sentence is carried out?
..
We each owe a death, there are no
exceptions, but sometimes, oh God,
the Green Mile is so long...


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]