LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   starting script, init by copy/create file in (samba) folder? (https://www.linuxquestions.org/questions/linux-general-1/starting-script-init-by-copy-create-file-in-samba-folder-335085/)

muab 06-19-2005 03:37 AM

starting script, init by copy/create file in (samba) folder?
 
hiho =)

im looking for a way to start a script as soon as a file is created(or copied) to a folder (via xp-pc on a samba folder).

is there a way?

note: cronjob every minute is "my way" atm, but im not happy with it as the script will run again and again, also i often have problems with still opened/not completely written files

thx
muab

nixcraft 06-19-2005 06:49 AM

Samba has two options called preexec and postexec:

Code:

preexec = /path/to/script &
postexec = /path/to/script &

By starting script in back ground you can have full control over it!

muab 06-19-2005 12:51 PM

many thx, its finally nearly working, at least once ;/

so when i (restart) sambad it works exactly one time.

so maybe 3 ideas why:

- i dont have a post exec, so the process isnt completed

- there is kinda timeout that has to be reached to be able to start the script again

- something else...

anyone just one more idea?

thx
muab

nixcraft 06-19-2005 02:24 PM

Quote:

Originally posted by muab
many thx, its finally nearly working, at least once ;/

so when i (restart) sambad it works exactly one time.

so maybe 3 ideas why:

- i dont have a post exec, so the process isnt completed

- there is kinda timeout that has to be reached to be able to start the script again

- something else...

anyone just one more idea?

thx
muab

If you need delay in script use
sleep SECONDS command inside loop
Code:

while :
do
  code
  code
. ..
....
 sleep 1 # ill sleep for 1 sec
done


muab 06-19-2005 04:37 PM

i allready tried thatm but the prob is that the script (in any way i treied so far) is executed just once =(

nixcraft 06-21-2005 08:48 AM

Did you run script as

/path/to/script &

muab 06-22-2005 04:42 PM

found out that a magic script would be exactly (well, nearly ;P) what i need..

but still trying to read howtos/faqs to get it run ;P

(whats that & for at the end of the line?)

artois_val 06-22-2005 06:02 PM

Hi, why do you whant to run a script when a file is copyed or creater over a samba share ?


Im just curious ;-)


All times are GMT -5. The time now is 09:43 AM.