Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'I was able to figure it out!' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
I was able to figure it out!
Authored by: pwharff on Oct 01, '03 02:41:31PM

I hope I did this correctly as I am new to perl. In my previous question I wanted to know if instead of notifying the user of changes, could it just do something else, like run a script? Well I digged around your script and this is what I changed (I hope this is ok under your terms?):

# print "$date: $filename: $msg\n";
system("sh /home/paul/CreateIndex") if $show_info;

This now runs my script when a particular folder is updated. This is much better than a cron job that runs the script every 5 minutes even if the folder wasn't updated.



[ Reply to This | # ]
re: running script
Authored by: hayne on Oct 01, '03 03:53:31PM
Of course there is no problem with you changing the script as you like. The license (Perl's "Artistic License") allows you to do more or less whatever you want as long as you maintain the copyright notice and indicate what things you changed.

Your changes to the watchfile script (to make it invoke another script when a change is detected) seem like they will do what you want. You might want to enhance your shell script to handle command-line arguments and then you could pass it interesting information such as which file got changed.
E.g.:
system("/bin/sh /home/paul/CreateIndex $filename") if $show_info

[ Reply to This | # ]

re: running script
Authored by: pwharff on Oct 01, '03 06:53:15PM

Cool, I had not thought of that. I will make the change now. And thanks again for writing this script. I found another program in Linux that does almost what yours does and is called watch.



[ Reply to This | # ]
I was able to figure it out!
Authored by: damjan on Dec 08, '03 03:35:47AM

hi ,

Is it possibile to change script to send email to let say administrator everytime some files in folder are changed?

how?

br
Damjan



[ Reply to This | # ]