LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-19-2005, 03:37 AM   #1
muab
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Rep: Reputation: 0
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
 
Old 06-19-2005, 06:49 AM   #2
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
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!
 
Old 06-19-2005, 12:51 PM   #3
muab
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Original Poster
Rep: Reputation: 0
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
 
Old 06-19-2005, 02:24 PM   #4
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
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
 
Old 06-19-2005, 04:37 PM   #5
muab
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Original Poster
Rep: Reputation: 0
i allready tried thatm but the prob is that the script (in any way i treied so far) is executed just once =(
 
Old 06-21-2005, 08:48 AM   #6
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
Did you run script as

/path/to/script &
 
Old 06-22-2005, 04:42 PM   #7
muab
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Original Poster
Rep: Reputation: 0
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?)
 
Old 06-22-2005, 06:02 PM   #8
artois_val
Member
 
Registered: Jan 2004
Posts: 35

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


Im just curious ;-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy in a script files to a samba folder? Julianus Linux - Networking 1 10-09-2004 07:29 PM
can copy-paste or create new file/folder, if boot from live cd gjo Linux - Distributions 3 09-17-2004 08:43 AM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM
Run script during file copy or create in directory neranjana Linux - General 1 01-13-2004 06:57 AM
Samba: how to create a logon script file when i add a system user. heero82 Linux - Software 2 06-19-2003 08:29 PM


All times are GMT -5. The time now is 05:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration