in reply to telnet from telnet
You need to change 'localhost', 'guest', and 'testme'.use strict; use Net::Telnet; $b = Net::Telnet->new( Output_record_separator => '', Prompt => '/\$ $/', Timeout => 20, Host => 'localhost', ); $b->login("guest\n", "testme\n") or die "Connect failed: @{ $b->errmsg +() }\n"; my @output = $b->cmd("who\n"); print "out @output\n"; @output = $b->cmd(q[ perl -w <<EOP use Net::Telnet; my \$c = Net::Telnet->new( Errmode => 'return', Telnetmode => 1, Output_record_separator => '', Prompt => '/\\\$ $/', Timeout => 10, Host => 'localhost' ); \$c->login( "guest\n", "testme\n" ) or die "Connect failed: @{ \$c->errmsg() }\n"; my @output = \$c->cmd("who\n"); print "out @output\n"; EOP ]); print "out @output\n";
UPDATE: did not have enought escaping. The prompt argument seems to be problematic.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: telnet from telnet
by Anonymous Monk on Apr 12, 2005 at 13:57 UTC |