srlbharu has asked for the wisdom of the Perl Monks concerning the following question:

Hi, How can we get the data received using the input buffer. Net::Telnet is having an API $ref = $obj->buffer; But how to use this api to get data. I tried to print $ref as print $$ref but nothing is printed.

  • Comment on Net::Telnet issue with getting input buffer data

Replies are listed 'Best First'.
Re: Net::Telnet issue with getting input buffer data
by Corion (Patriarch) on Feb 28, 2013 at 13:16 UTC

    Quoting Net::Telnet:

    This method returns a scalar reference to the input buffer for $obj. Data in the input buffer is data that has been read from the remote side but has yet to be read by the user.

    So, the following use would be correct:

    my $ref= $obj->buffer; print "Unread buffer is '$$ref'\n";

    If that is empty, then there is no unread data.

Re: Net::Telnet issue with getting input buffer data
by regexes (Hermit) on Feb 28, 2013 at 13:18 UTC
    I don't know exactly what you are trying to do, however, the first place to look is the documentation. Net::Telnet

    You mention: "But how to use this api to get data."
    To me, this means: "How do I use the module to send commands and receive the output of those commands".

    Begin with a reasonable prompt. For example, see this thread: Re: Net::Telnet + command prompt

    For the rest... a good place to start is to read about the methods cmd(), waitfor() and print() from the documentation. There are also some good examples at the bottom of the page as well.
Re: Net::Telnet issue with getting input buffer data
by perl514 (Pilgrim) on Feb 28, 2013 at 18:30 UTC

    Hi,

    Apologies for this off topic comment, but, do you have to use Net::Telnet or would you be ok with an SSH2 based module like say Net::SSH2 ? If so please go through the excellent writeup: A little demo for Net::SSH2

    Perlpetually Indebted To PerlMonks

    use Learning::Perl; use Beginning::Perl::Ovid; print "Awesome Books";
    http://dwimperl.com/windows.html is a boon for Windows.