Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Welcome to the Monastery
 
PerlMonks  

Re: coming out of perl script after 10 min.

by moritz (Cardinal)
on Mar 05, 2013 at 09:04 UTC ( #1021775=note: print w/ replies, xml ) Need Help??


in reply to coming out of perl script after 10 min.

alarm sounds like the right approach here. So you need to show your code (reduced to the relevant part) here, otherwise we can't know what's wrong with it.

See also: How (Not) To Ask A Question


Comment on Re: coming out of perl script after 10 min.
Re^2: coming out of perl script after 10 min.
by venky4289 (Novice) on Mar 05, 2013 at 10:40 UTC
    #!/usr/bin/perl eval { local %SIG; $SIG{ALRM}= sub{ die "timeout reached, after 20 seconds!\n"; }; alarm 20; print "sleeping for 60 seconds\n"; #sleep 60; # This is where to put your code, between the alarms $x=<stdin>; alarm 0; }; alarm 0; if($@) { print "Error: $@\n"; } exit(0);
    Here we should enter some input, but my requirement is if the input is not enetered in 20 sec, it should come out of the program(Exit the program).
      but my requirement is if the input is not enetered in 20 sec, it should come out of the program(Exit the program).

      And that's what the program does (as far as I can tell; but hard to tell, since it is formatted so badly here). Which is why I wonder what your actual question is.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-04-18 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (460 votes), past polls