hey guys i need help

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.

$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
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

In reply to killing command if it takes too much time by perlassassin27

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.