Telent in Perl with no Prompt

I need to open a telnet session in perl and capture the output to a file.  The device has no prompt basically I telnet in send the command STS and it returns a string.
Does anyone have a script for this, everything I have found here doesnt work.
LVL 1
johnnygonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adam314Commented:
You can use Net::Telnet, just don't use the cmd or login methods.  You can still send data, and receive data though.
0
johnnygonAuthor Commented:
Do you have an example?  I just get nothing back.
0
Adam314Commented:
Do you send newline characters after the commands?  If not, you need to change the output record separator.  Otherwise, this should work.
use Net::Telnet;
 
my $telnet = Net::Telnet->new(
  Dump_Log   => 'dump.log',
  Input_log  => 'input.log',
  Output_log => 'output.log',
  Host       => 'your-hostname-here',
  );
 
##### Send username/password, if needed
$telnet->print("username");
$telnet->print("password");
 
##### If there is anything that lets you know you logged in successfully, look for it
$telnet->waitfor('/You are logged in/');
 
##### Send whatever else is needed
$telnet->print('STS');
 
##### Do you need to wait for something, or wait a certain amount of time?
my $output = $telnet->get(Timeout => 10);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnnygonAuthor Commented:
What if I want to send another print based on the response I get from the get? It doesnt seem to want to loop.
0
Adam314Commented:

...
if($output =~ /my expected output/) {
    $telnet->print('some new command');
}

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.