client/server using Net::Telnet fails under certain conditions. Help please

R

Robert

I wrote a server that listens for an input array of 1 or more elements. It
conducts a conditional loop looking for key patterns in array element [0].
Based upon the match the server executes a predetermined function e.g. if
($in[0] =~ /pattern/) { do something }. It works great when I telnet to the
assigned port on the host the server is listening to. That is,

telnet hostname 12000
fs
<execute a df from server>

When I run my client some of the commands work, $shell->print('some
command'), and some don't. I have tried closing the socket and reopening
it, turned on all the error messages I know about, print to the LOG files.
What I have determined is that the call to

open(CMD,"| ps -ef") or print LOG "ps failed $!\n"; fails to either
work (which I doubt since the log file doesn't have any entires for that
failure or the $shell->getlines(); is not receiving any input. Remember, it
works fine when I telnet manually. Any ideas as to why it is failing.
Thanx in advnace.

______END_____


$shell =
Net::Telnet->new(Host=>$host,Port=>$port,Timeout=>60,Errmode=>'return');
$shell->input_log($logfile);
$shell->dump_log($dumplog);
$fs_array = get_fs(); <<<<<<<<<<<< goes to server to execute and return a
df. Works fine!

($filesystems,$h_lvols) = clean_data($fs_array); <<<<<<<<< Not a
Net::Telnet sub.

$filesys = select_fs($filesystems); <<<<<<<< not a Net::Telnet sub.

($startd,$stopd) = select_dates(); <<<<<<<<<< not a Net::Telnet sub.

begin_extract($extract,$startd,$stopd); <<<<<< Net::Telnet sub. works
when I take out the following while loop and replace with sleep for 40.
$line = $shell->lastline;
print "This is lastline 1 $lastline\n";
$result = $shell->errmsg;
print "Error msg 1 $result\n";

$shell->close();
$shell =
Net::Telnet->new(Host=>$host,Port=>$port,Timeout=>60,Errmode=>'return');
while (1) {
print "XXX\n";
$shell->print("psef");
@psarray = $shell->getlines(); <<<<<<<<<<<<<< seems to fail here in that
nothing is returned to @psarray.
$line = $shell->lastline;
print "This is lastline 2 $lastline\n";
$result = $shell->errmsg;
print "Error msg 2 $result\n";
chomp(@psarray);
if (grep { /extract/ } @psarray ) {
print "grep match\n";
sleep 5;
} else {
print "last ---*\n";
last;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top