Hello again Anonymous Monk,

I noticed that the monks have helped you already and propose some alternative solutions to your problem.

As blindluke guessed you are propably using Net::Telnet, but I would also like to propose an alternative solution that it will work if the router supports ssh.

At this point I remembered that in the past I used Net::OpenSSH on a Sierra modem to execute a few commands (if it supports ssh).

I created a sample of code that it does exactly what you need and pipes the output to your local OS. I am using a command for Linux, so you have to change the command and test it. I think it will work, I am not 100% sure because you said it is VoIP router but worth the effort of trying.

Sample of running code with output printed from the file.

#!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; my $host = "127.0.0.1"; # remote IP my $port = 22; # ssh default 22 change it my $passwd = "username"; my $user = "password"; my %opts = ( passwd => $passwd, port => $port, user => $user ); my $ssh = Net::OpenSSH->new( $host , %opts ); $ssh->error and die "Couldn't establish SSH connection: ". $ssh->error; my ($rout, $pid) = $ssh->pipe_out("vmstat") or die "pipe_out method failed: " . $ssh->error; open my $write, ">", "test.txt" or die $!; while (<$rout>) { print $write $_; } close $rout; close $write; open my $read, "<", "test.txt" or die $!; while (my $row = <$read>) { chomp $row; print "$row\n"; } close $read; __END__ Check also the test.txt file it contains the same output procs -----------memory---------- ---swap-- -----io---- -system-- ---- +--cpu----- r b swpd free buff cache si so bi bo in cs us s +y id wa st 1 0 68716 390444 9520 674036 0 1 25 27 217 235 8 +2 89 1 0

I hope this helps, let me know if it worked.

Ps: please change the title of your question to something more appropriate, read I want to ask a question of the Perl Monks; where do I start?, How do I post a question effectively? and importantly Select an informative title.. It will only take you a few minutes.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Newbee needs help by thanos1983
in thread Newbee needs help by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.