Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lines from Net::Telnet

Status
Not open for further replies.

lvennard

MIS
Apr 20, 2000
93
US
This should be simple, but I'm doing something stupid. Im just trying to read the @lines from a command using Net::Telnet. I've followed the example, but still having trouble. My input_log shows the whole transaction, but it doesnt come out in the @lines array like it should... can anyone see whats wrong?

use Net::Telnet ();
$t = new Net::Telnet (Timeout => 10, Prompt => '//', Input_log => "sess.txt");
$t->open($hostip);
#$t->waitfor('/:/');
$t->login($username, $passwd);
$t->waitfor('/#/');
@lines = $t->cmd('who');
$t->waitfor('/#/');
print @lines;

Heres what happens when I run it
[root@server /test_dir]# ./test.pl
[root@server /test_dir]#

(Notice, no output)

Here is my input file Sess.txt

User Access Verification

Username: lvennard
Password:

switch#who
Line User Host(s) Idle Location
* 1 vty 0 lvennard idle 00:00:00 testbox

Interface User Mode Idle Peer Address

switch#
 
Got it... had to change the prompt line to be more specific.... (the waitfor lines are pulled from the new file, but didnt need to be for it to work)

use Net::Telnet ();
$t = new Net::Telnet (Timeout => 5, Prompt => '/[#:]/', Input_log => "sess.txt");
$t->open($hostip);
$t->login($username, $passwd);
@lines = $t->cmd('who');
print @lines;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top