How to get the output from telnet commands in Perl?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeetendra G

    How to get the output from telnet commands in Perl?

    Code:
    use Net::telnet
    telnet->open($host);
    telnet->logint("rrot","rut"
    $a=telnet->cmd("ls");
    using telnet i am running this command to remote machine its is connecting to remote machine.
    but the output of "ls" is not coming in $a.
    a is having the status of the ls command it is not having results .a is having 0 or 1.
    ouput is not coming in a
    Last edited by Dormilich; Nov 5 '10, 06:18 AM. Reason: please use [CODE] [/CODE] tags when osting code
  • toolic
    Recognized Expert New Member
    • Sep 2009
    • 70

    #2
    Try to capture the cmd output into an array variable instead of a scalar variable:

    Code:
    my @lines = $telnet->cmd("ls");
    This is discussed in the cmd section of the Net::Telnet documentation.

    Comment

    Working...