Solved

Telnet comand

Posted on 2002-05-07
6
358 Views
Last Modified: 2009-12-16
I need a script that connect to a server, make the login, run a command and print the output.

How to do it?

0
Comment
Question by:oleber
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 6

Expert Comment

by:sstouk
ID: 6994207
1) Install the Net::Telnet Module;

2) Try the following:

   use Net::Telnet ();
    $t = new Net::Telnet (Timeout => 15,
                          Prompt => '/bash\$ $/');
    $username = "";
    $passwd = "password";
    $t->open("systemIP");
    $t->login($username, $passwd);
    @lines = $t->cmd("dir");
    print @lines;
0
 
LVL 10

Author Comment

by:oleber
ID: 6994322
I have this error

'timed-out waiting for command prompt' in this line '$t->login($username, $passwd);'

I'm in windows

manual telnet works
0
 
LVL 8

Accepted Solution

by:
bebonham earned 75 total points
ID: 6994402
:

  use Net::Telnet ();
   $t = new Net::Telnet (Timeout => 15);
   $username = "";
   $passwd = "password";
   $t->open("systemIP");
   $t->login($username, $passwd);
   @lines = $t->cmd("dir");
   print @lines;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Author Comment

by:oleber
ID: 6996502
The command that I execute takes many time. But it gives output every n seconds. Can I see that output in me script when is prodiced.

Thanks

0
 
LVL 8

Expert Comment

by:bebonham
ID: 6996602
no not as it is
0
 
LVL 6

Expert Comment

by:sstouk
ID: 6996838
I am sure it's something to do with the
(Prompt => '/bash\$ $/';)
Option.
The Script expects a specific prompt from the terminal server to make sure that the server has completed the output and is expecting for the command.
You will have to try different matching strings to make sure that there is a match of the prompt that script will expect.
This is custom to the terminal server.

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question