Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Telnet comand

Posted on 2002-05-07
6
Medium Priority
?
360 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
  • 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 300 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
Independent Software Vendors: 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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.…
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

916 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