Solved

Telnet comand

Posted on 2002-05-07
6
354 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
execute pl/sql block from perl program 3 119
Which version of C should I use when Perl is too slow? 13 173
Perl script to parse xml file 2 104
combine multiple lines 2 44
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 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

18 Experts available now in Live!

Get 1:1 Help Now