Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Hi all,

I was wondering if someone could lend me a solution. :(

I have a list of commands (user defined perl module subroutine) in a text file, that my script reads in one at a time, and then I try to execute as below.

eval $cmd

Each command will wait for response for 90sec to go for next command.

Here one of my command should not wait for the response to go further commands.

I tried as below but failed by getting a popup menu:

"Perl Command Line Interpreter has encountered a problem and needs to +close"
Also I got error in the Perl cmd prompt:Attempt to free unreferenced scalar

foreach (@commands) { $cmd = $_; if($cmd =~ /PLA_ENABLE/i){ $pid = fork(); if (defined $pid && $pid == 0) { # child eval $cmd; } exit 0; } else{ eval $cmd; } }
$cmd will be holding commands like MCI->Do("SETP NAS_R99_QOS 0");
sub Do { my ($self, $cmd, $time_out) = @_; my ($TimeOut, @lines, $StopTime); my ($prematch, $result, $retVal); my ($success, @reply); my $nice = 0; my $linecount = 0; tie $retVal, 'ReturnValue'; $retVal = PASS; # Empty the input buffer $self->{_tnet}->buffer_empty; # Clear the last error message $self->{_tnet}->errmsg(@reply); #cut newline if there is one chomp $cmd; print $gLog Text => "$cmd\n", Name => $self->{_name}; if ($cmd =~ /Wait/) { # MDL 'Wait' command can be used in scripts, but is not recogn +ised by MCI... # Engine provides a 'Wait' function, but sometimes 'Wait' is i +n a TM script and does not get # sent to the Engine 'Wait' function because it doesn't end in + a semicolon. $cmd =~ s/^\s+//; my $waittime = ${[split /\s+/, $cmd]}[1]; return $gEngine->Wait($waittime); } #If time out is defined this sets the time out. if (defined($time_out)) { if ($time_out =~/^[0-9]+$/) { $TimeOut = $time_out; } else { print $gLog Text => "Invalid time out provided using 90sec +s.\n", Color => "blue", Name => $self->{_name}; $TimeOut = 90; } } else { $TimeOut = 90; } $_ = $cmd; # SCFG timeout is 15 minutes. /SCFG/i && do { $TimeOut = 900; $nice = 1; }; # initcellsearch timeout is now 60 seconds. /initcellsearch/i && do { $TimeOut = 60; }; # Send command. $self->{_tnet}->timeout(1); $success = $self->{_tnet}->print( $cmd ); if (!$success) { print $gLog Text => "Sending the command $cmd to the mobile f +ailed\n", Color => "red", Name => $self->{_name}; return $self->_checkfailures($cmd); } $StopTime = time + $TimeOut; # Wait for reply - matches the presence of a 'C:' $result = ""; WAIT: { do { undef @lines; _sleep_for(0.05) if ($nice); @lines = $self->{_tnet}->getlines(TimeOut => 0); foreach $prematch (@lines) { push @reply, $prematch; $result .= $prematch; } if (time > $StopTime) { print $gLog Text => "Confirmation C: not received fro +m mobile in $TimeOut seconds. Checking for errors.\n", Color => 'red' +, Name => $self->{_name}; $retVal = $self->_checkfailures($cmd); last WAIT; } } until (($result =~ /C:\s*(\w+)\s*0x\d\d/i) || ($result =~ /O +K/i)); } # Count the number of lines received in the WAIT loop. $linecount = @reply; if ($linecount > 0) { # Print the line. Scan it for errors and set the state accordi +ngly. $retVal = $self->_printReturnedLines($result); } else { # Fatal error as no lines were received. $retVal = FATAL; } return $retVal if (($retVal == FATAL) || ($retVal == CRASH)); $retVal = $self->Pass_Conf_Ind(@lines, $cmd); return wantarray ? ($retVal, $result) : $retVal; }

In reply to eval a command by Xantara

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (7)
    As of 2014-04-20 20:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (487 votes), past polls