Solved

Telnet comand

Posted on 2002-05-07
6
353 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
Comment Utility
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
Comment Utility
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
Comment Utility
:

  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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Author Comment

by:oleber
Comment Utility
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
Comment Utility
no not as it is
0
 
LVL 6

Expert Comment

by:sstouk
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now