perlassassin27 has asked for the wisdom of the Perl Monks concerning the following question:
i am running a perl script on a unix/linux dev box. where i need the script to send a command and if its taking too much time for the command to be be completed i want it to report an error and post on the error log.
well i know i made a mistake in the while statement as it does the thing again and again until it doesnt exit.bt i want it to run the pullcmd statement and then exit if its pass d timeout and i cant think of any other way$pull_cmd = "expect ssh.exp sid\@".$ipaddress." \"scp root\@comp2:/tmp +/10mbfile /tmp/\" perlassasin27";} my $timer=0; while((@returned_lines)=` $pull_cmd`) { $timer++; print "TIME:$timer\n"; + #debug message my $filesize = $bs * $count; my $timeout=((0.000012968376*$size)-1. +0862736)*2; if ($timer>$timeout) { open(ERROR_LOG,">ErrorLog-$Opt +ions{device}.log"); print ERROR_LOG "THE File is t +aking too long to transfer than anticipated. Check Connection."; close(ERROR_LOG); print "ERROR. check log for mo +re details.\n"; exit(1); } } my $size = $bs * $count; my $timeout=((0.000012968376*$size)-1. +0862736)*2; print "this is file size:$size\nthis is timeou +t time in sec: $timeout\n"; #debug Message
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: killing command if it takes too much time
by Argel (Prior) on Feb 10, 2011 at 00:02 UTC | |
|
Re: killing command if it takes too much time
by pemungkah (Priest) on Feb 09, 2011 at 23:37 UTC | |
|
Re: killing command if it takes too much time
by salva (Canon) on Feb 10, 2011 at 00:42 UTC | |
|
Re: killing command if it takes too much time
by eyepopslikeamosquito (Archbishop) on Feb 10, 2011 at 04:32 UTC |