|
From: mmccaws2 on 2 Apr 2008 12:11 I have a user interface script that makes changes in a db or makes db queries. I don't want the user to just leave the script running all the time. what is the best way to monitor if the script has had no actiivty for 20 minutes? Thanks Mike
From: jjcassidy on 2 Apr 2008 12:22 On Apr 2, 12:11 pm, mmccaws2 <mmcc...(a)comcast.net> wrote: > I have a user interface script that makes changes in a db or makes db > queries. I don't want the user to just leave the script running all > the time. what is the best way to monitor if the script has had no > actiivty for 20 minutes? > > Thanks > > Mike You'd need to use *some kind* of persistence. Cheapest NIX-ish way is to have a dummy file that you "touch" when you exit the program--or whenever a significant event occurs, if you occasionally "sleep". If you "stat" the file, you know how long it's been since it's been "touch-ed". Other than that, it's your choice of persistence: write and read time to and from a file; use Storable or YAML to dump a hash with all the values you care about; use a database....
From: Mark on 2 Apr 2008 14:59 On Apr 2, 9:11 am, mmccaws2 <mmcc...(a)comcast.net> wrote: > I have a user interface script that makes changes in a db or makes db > queries. I don't want the user to just leave the script running all > the time. what is the best way to monitor if the script has had no > actiivty for 20 minutes? > > Thanks > > Mike Perhaps this sample code (works on my Linux box but doesn't work on my Windows XP box) may help: use strict ; use warnings ; $| = 1 ; my $timeout = 20 * 60 ; # twenty minutes my $rin = '' ; vec($rin,fileno(STDIN),1) = 1; my $ein = $rin ; while () { print "waiting for input\n" ; my $nfound = select(my $rout=$rin, undef, my $eout=$ein,$timeout); if (vec($eout,fileno(STDIN),1)) { die "error detected on STDIN" ; } elsif (vec($rout,fileno(STDIN),1)) { my $ans = <STDIN> ; print "got: $ans\n" ; } else { print "timed out\n" ; } }
From: mmccaws2 on 2 Apr 2008 15:07 On Apr 2, 9:22 am, jjcass...(a)gmail.com wrote: > On Apr 2, 12:11 pm, mmccaws2 <mmcc...(a)comcast.net> wrote: > > > I have a user interface script that makes changes in a db or makes db > > queries. I don't want the user to just leave the script running all > > the time. what is the best way to monitor if the script has had no > > actiivty for 20 minutes? > > > Thanks > > > Mike > > You'd need to use *some kind* of persistence. Cheapest NIX-ish way is > to have a dummy file that you "touch" when you exit the program--or > whenever a significant event occurs, if you occasionally "sleep". If > you "stat" the file, you know how long it's been since it's been > "touch-ed". > > Other than that, it's your choice of persistence: write and read time > to and from a file; use Storable or YAML to dump a hash with all the > values you care about; use a database.... so everytime enter is hit log it and have the same script check that or a different script monitor it? I'm not familiar with storable or yaml, what keyword search would I use to help narrow down the choices? Thanks Mike
From: mmccaws2 on 2 Apr 2008 15:12
On Apr 2, 12:07 pm, mmccaws2 <mmcc...(a)comcast.net> wrote: > On Apr 2, 9:22 am, jjcass...(a)gmail.com wrote: > > > > > On Apr 2, 12:11 pm, mmccaws2 <mmcc...(a)comcast.net> wrote: > > > > I have a user interface script that makes changes in a db or makes db > > > queries. I don't want the user to just leave the script running all > > > the time. what is the best way to monitor if the script has had no > > > actiivty for 20 minutes? > > > > Thanks > > > > Mike > > > You'd need to use *some kind* of persistence. Cheapest NIX-ish way is > > to have a dummy file that you "touch" when you exit the program--or > > whenever a significant event occurs, if you occasionally "sleep". If > > you "stat" the file, you know how long it's been since it's been > > "touch-ed". > > > Other than that, it's your choice of persistence: write and read time > > to and from a file; use Storable or YAML to dump a hash with all the > > values you care about; use a database.... > > so everytime enter is hit log it and have the same script check that > or a different script monitor it? I'm not familiar with storable or > yaml, what keyword search would I use to help narrow down the choices? > > Thanks > > Mike Mark our posts crossed, I'll try that Mike |