LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-06-2011, 11:27 AM   #1
abhiduke
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Rep: Reputation: Disabled
Question 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.
 
Old 08-06-2011, 11:39 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
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
 
Old 08-06-2011, 11:50 AM   #3
abhiduke
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Question

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.
 
Old 08-06-2011, 01:00 PM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,620

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by abhiduke View Post
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.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if actions in bash shell script are performed well proNick Linux - Newbie 6 02-09-2009 08:25 PM
shell script (continuous pinging and actions when host is up) xtraya Programming 4 02-19-2008 08:11 PM
Auto ftp shell script mcrosby Linux - Newbie 9 06-27-2007 07:09 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
auto execute shell script ykirankumar Linux - Software 3 09-22-2004 08:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration