Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Running a script iteratively.

by mscharrer (Hermit)
on Apr 24, 2008 at 14:57 UTC ( #682649=note: print w/replies, xml ) Need Help??


in reply to Running a script iteratively.

Under an Unix installations (e.g. Linux) you could use a cron job for this and tell it to start the script every two minutes. Just google after 'cron job'.

To code it in perl, e.g. for Windows without cron daemon, you could write something like this:

while ( 1 ) { system("perl get_value.pl"); sleep(120); }
This would delay for two minutes after the get_values script ended. You might want to add an possibility to stop this loop without killing the perl process.

Update: This might look like a repost of an above post, but I got interrupted for an half hour after I wrote this post but before I could sent it. Afterwards I was just sending it without checking if anyone else gave the same answer in the meantime.

Replies are listed 'Best First'.
Re^2: Running a script iteratively.
by moklevat (Priest) on Apr 24, 2008 at 15:21 UTC
    It's OK, you used system. My backticks were met with revulsion. :-)

      I'll see your revulsion and raise you a silent bug. The above used system without separating the arguments, or checking return value. The perldoc shows better practice. If you're writing immutable code on your own box, you can obviously shove it all into one string but it's not a habit to cultivate.

      my @args = qw( perl get_value.pl ); system(@args) == 0 or die "system @args failed: $?"
Re^2: Running a script iteratively.
by Anonymous Monk on Apr 26, 2008 at 07:10 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://682649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2021-06-23 09:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (117 votes). Check out past polls.

    Notices?