Solved

Net::Telnet prompt issue

Posted on 2004-10-05
3
1,524 Views
Last Modified: 2012-06-27
Hi Experts,

I have a perl script that is using Net::Telnet and it gets as far as teh login prompt.

the session is a specific interface and retruns the following promtps when I telent from any host.

Enter User Name:
Enter User Password:

it my current script, it opens the socket and times out waiting for the proper login prompt.

how can i set my prompt to make this work.

here is a snipit of my code:

 use Net::Telnet ();
   my $username = "fred";
   my $passwd = "flintstone";
   my $ip = 10.1.1.1;
   my $t = new Net::Telnet(Prompt => '/Enter User Name:/ ');
    $t->open($ip);
    $t->login($username, $passwd);

any help here is greatly appreciated.

Thanks

Rootman 103
0
Comment
Question by:rootman103
  • 2
3 Comments
 

Accepted Solution

by:
nanoterabeta earned 125 total points
ID: 12233423
In most cases, you don't have to use Prompt, just simple like:
  $telnet = new Net::Telnet ( Timeout=>15,
                              Errmode=>'die',
                             Port => 23
            );
$telnet->open($ip);
$telnet->print($username);
$telnet->print($passwd);
because the user prompt and password prompt will be sent by the host to you successively right after you make a new telnet to the hosts.
Good luck.
0
 

Author Comment

by:rootman103
ID: 12233561
awesome, this worked.

now all i need to do is get it ot print my end results.


Thanks,

Rootman 103
0
 

Author Comment

by:rootman103
ID: 12255110
sorry for the delay in giving you the points.

Thanks again.

Rootman103
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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 hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

770 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