Hi,
Can a shell script contiuously poll for a specific file in a specified directory, and upon finding such a file, execute some commands.
Can someone please suggest if this is possible & suggest some way to implement it.
regards, Sandeep
Sometime today, Linux @ Ramshyam wrote:
Can a shell script contiuously poll for a specific file in a specified directory, and upon finding such a file, execute some commands.
Yes, perhaps you should send the script into an infinite loop which only exits when it finds the file to exist. Here's a bad way of doing it -
while [ ! -f tmp.txt ]; do : done echo "File found... executing commands."
A better way would be to let it sleep for some time between successive polls.
Manish
Thx manish, Where can I get some ONLINE book for SHELL SCRIPTING. Sandeep
Sometime today, Linux @ Ramshyam wrote:
Can a shell script contiuously poll for a specific file in a specified directory, and upon finding such a file, execute some commands.
Yes, perhaps you should send the script into an infinite loop which only exits when it finds the file to exist. Here's a bad way of doing it -
while [ ! -f tmp.txt ]; do : done echo "File found... executing commands."
A better way would be to let it sleep for some time between successive polls.
Manish
Linuxers mailing list Linuxers@mm.ilug-bom.org.in http://mm.ilug-bom.org.in/mailman/listinfo/linuxers
Sometime today, Linux @ Ramshyam wrote:
Where can I get some ONLINE book for SHELL SCRIPTING.
Adv-Bash-Scr-HOWTO http://www.linuxdoc.org/HOWTO/Adv-Bash-Scr-HOWTO/index.html
For the purpose of this script, look up the bash manual. "man bash". "man sleep".
Maybe you can replace the colon with a call to sleep.
while [ ! -f tmp.txt ]; do sleep 3 # Sleep for 3 seconds. done echo "File found... executing commands."
Manish
hi sandeep...
i've one book uploaded...... if u want to try it url is
http://nttindia.com/ranjeet/unix/
regards, ranjeet
At 11:41 AM 7/24/01 +0530, you wrote:
Thx manish, Where can I get some ONLINE book for SHELL SCRIPTING. Sandeep
Sometime today, Linux @ Ramshyam wrote:
Can a shell script contiuously poll for a specific file in a specified directory, and upon finding such a file, execute some commands.
Yes, perhaps you should send the script into an infinite loop which only exits when it finds the file to exist. Here's a bad way of doing it -
while [ ! -f tmp.txt ]; do : done echo "File found... executing commands."
A better way would be to let it sleep for some time between successive polls.
Manish
Linuxers mailing list Linuxers@mm.ilug-bom.org.in http://mm.ilug-bom.org.in/mailman/listinfo/linuxers
Linuxers mailing list Linuxers@mm.ilug-bom.org.in http://mm.ilug-bom.org.in/mailman/listinfo/linuxers
Sometime on Jul 23, Manish Jethani assembled some asciibets to say:
Can a shell script contiuously poll for a specific file in a
Yes, perhaps you should send the script into an infinite loop
Polling is always done with pseudo infinite loops. pseudo infinite because although not strictly an infinite loop (while 1), there is no guarantee that the condition will match.
sleeping for about five seconds between polls is how I do it.
Philip
Any particular reason why all insist for a 5 Sec nap. Sandeep
Sometime on Jul 23, Manish Jethani assembled some asciibets to say:
Can a shell script contiuously poll for a specific file in a
Yes, perhaps you should send the script into an infinite loop
Polling is always done with pseudo infinite loops. pseudo infinite because although not strictly an infinite loop (while 1), there is no guarantee that the condition will match.
sleeping for about five seconds between polls is how I do it.
Philip
-- The universe is like a safe to which there is a combination -- but the combination is locked up in the safe. -- Peter DeVries
Visit my webpage at http://www.ncst.ernet.in/~philip/ Read my writings at http://www.ncst.ernet.in/~philip/writings/
MSN philiptellis Yahoo! philiptellis
Linuxers mailing list Linuxers@mm.ilug-bom.org.in http://mm.ilug-bom.org.in/mailman/listinfo/linuxers
On Tue, 24 Jul 2001, Linux @ Ramshyam wrote:
Any particular reason why all insist for a 5 Sec nap.
5 is the third prime number. 5 is the fifth fibonacci number. 5 is the number of corners on a pentagram. 5 is the number of working days a week should have.
No! There's no particular reason.
Hey good one ... Actually what I mean is why a nap.. I mean what if it is non-stop polling... Sandeep
On Tue, 24 Jul 2001, Linux @ Ramshyam wrote:
Any particular reason why all insist for a 5 Sec nap.
5 is the third prime number. 5 is the fifth fibonacci number. 5 is the number of corners on a pentagram. 5 is the number of working days a week should have.
No! There's no particular reason.
-- Catharsis is something I associate with pornography and crossword puzzles. -- Howard Chaykin
Visit my webpage at http://www.ncst.ernet.in/~philip/ Read my writings at http://www.ncst.ernet.in/~philip/writings/
MSN philiptellis Yahoo! philiptellis
Linuxers mailing list Linuxers@mm.ilug-bom.org.in http://mm.ilug-bom.org.in/mailman/listinfo/linuxers
On Tue, 24 Jul 2001, Linux @ Ramshyam wrote:
Actually what I mean is why a nap.. I mean what if it is non-stop
There's better things that the CPU could do than keep running your program. Polling is never good. Event driven programming is better. Unfortunately, not all systems are event driven. Cron is a better option, since it runs regularly anyway.
Philip
HI All,
When tring to print from a DOS machine using foxpro application, I get the following error.... SHELL-332.-69: NETWORK SPOOLER ERROR: PROBABLY OUT OF SPACE ON VOL SYS: No errors when printing from EDIT.COM
Any idea what this error means & where should I look for solutions...
Thx sandeep
Hi, How can I search for a value of a variable [ f I may call iso] in a given file....
Say I have file ... \root\sandeep\log111.txt This files has a lot of text and one particulr line is ..... ##Date 24-07-2001
Now 1. I need to locate the line "##Date" in the above file 2. I then need to store the date value "24-07.2001" in a variable.
How can I do this, any suggestion please..... Thx sandeep
Sometime today, Linux @ Ramshyam wrote:
Say I have file ... \root\sandeep\log111.txt
You mean /root/sandeep/log111.txt
This files has a lot of text and one particulr line is ..... ##Date 24-07-2001
Depends on your programming environment. You didn't mention anything about it.
Assuming you want to do it from the shell -
LOG_FILE=/root/sandeep/log111.txt MY_DATE=$(egrep '^##Date +.+$' $LOG_FILE | tr -s ' ' | cut -f2 -d' ') echo $MY_DATE # Should display the date
Manish
Sometime Today, Linux @ Ramshyam assembled some asciibets to say:
How can I search for a value of a variable [ f I may call iso] in a given file....
There's a program called grep :-P that does this. man grep
Say I have file ... \root\sandeep\log111.txt This files has a lot of text and one particulr line is ..... ##Date 24-07-2001
Now
- I need to locate the line "##Date" in the above file
- I then need to store the date value "24-07.2001" in a variable.
After you get the line, use cut to get the relevant part. The entire script follows:
VAR=$( cat filename | grep "##Date [0-3]?[1-9]-[01]?[1-9]-200[01]" | cut -f2 -d" " )
Note, all the above is on one line.
I have used a very generic date grep. This will also find invalid dates, but if you're sure that all the dates are valid and that the format is exactly as given above, then this will work.
Philip
Sometime yesterday, Philip S Tellis wrote:
VAR=$( cat filename | grep "##Date [0-3]?[1-9]-[01]?[1-9]-200[01]" | cut -f2 -d" " )
That's too much for a simple problem, and not all right anyways. You are a Technical Thug (TM). :-)
Manish
On Tue, 24 Jul 2001, Linux @ Ramshyam wrote:
When tring to print from a DOS machine using foxpro application, I
where does linux fit into this?
--- "Linux @ Ramshyam" linux@ramshyam.com wrote:
HI All,
When tring to print from a DOS machine using foxpro application, I get the following error.... SHELL-332.-69: NETWORK SPOOLER ERROR: PROBABLY OUT OF SPACE ON VOL SYS: No errors when printing from EDIT.COM
Any idea what this error means & where should I look for solutions...
Novell Netware print error - check the Novell online documentation, and please preface the subject of such posts with [OT].
Krishnan
__________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/