On 7/8/11 Fri  Jul 8, 2011  12:43 PM, "Irfan Sayed"
<irfan_sayed2...@yahoo.com> scribbled:

> here is the actual code
> 
> 
> use Net::Telnet;
> $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die');
> $telnet->open('10.216.119.53');
> $telnet->waitfor('/login: $/i');
> $telnet->print('abc');
> $telnet->waitfor('/password: $/i');
> $telnet->print('xyz');
> $telnet->waitfor('/\$ $/i');
> $telnet->print('ls');
> $output = $telnet->waitfor('/\$ $/i');
> print $output;
> 
> 
> now, what i expect is, programme shud print the content of $output on the
> console 
> 
> the $output shud have the value of the result of "ls" command
> 
> plz suggest 

Please read the documentation for Net::Telnet, which says that the print
function returns 1 if all data was successfully written. If you wish to
capture the output from a command executed on the telnet server, use the
cmd() function and assign the function return to an array, not a scalar:

my @output = $telnet->cmd('ls');
print @output;




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to