LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   auto start shell script on other actions (https://www.linuxquestions.org/questions/linux-newbie-8/auto-start-shell-script-on-other-actions-895917/)

abhiduke 08-06-2011 11:27 AM

auto start shell script on other actions
 
I have a particular script xxxx in folder yyyy. How can i start/execute xxxx whenever i open or cd into yyyy.

corp769 08-06-2011 11:39 AM

Hello,

First, you need to chmod your script so you can execute it with the following command:
Code:

chmod +x script.py
After that, you would start the script as follows:
Code:

./script.py
Cheers,

Josh

abhiduke 08-06-2011 11:50 AM

but how do i start the script whenever i access that particular folder.

suppose i am opening the directory Videos in $HOME directory, i need to auto start a particular script which will log the files i access in Videos directory.

crts 08-06-2011 01:00 PM

Quote:

Originally Posted by abhiduke (Post 4435335)
but how do i start the script whenever i access that particular folder.

suppose i am opening the directory Videos in $HOME directory, i need to auto start a particular script which will log the files i access in Videos directory.

Hi,

consider using 'incrond' for this task. Read this post to get an idea on how to configure it:
http://www.linuxquestions.org/questi...6/#post3855217

The above linked example monitors file creation in a certain directory. You will have to make the appropriate adjustments to make it work for your purposes, e.g. the event you are probably interested in is 'IN_ACCESS'.

Here is some more info on 'incrond':
http://linux.die.net/man/5/incrontab
http://linux.die.net/man/5/incron.conf
http://linux.die.net/man/8/incrond

Let us know if you get stuck at some point.

Hope this helps.


All times are GMT -5. The time now is 12:24 PM.