Hi I have put together a a basic telnet script script . I can get it to work fine for simple commands but what I want to do is replicate a script I user over ssh to spool the <STDOUT> to a file. The problem I keep hitting is the script runs and produces a page of info with a more at the bottom and then halts and then the script times out. I know it is doing this as I trace the TCP connection with ethereal and I can see the command execute and return a screen full of data with the more at the bottom

The basic script looks like this. If I change the comand to an 'ls' it works a treat

use Net::Telnet (); use warnings; my $host ='somehost'; my $username ='user'; my $passwd = 'password'; #my $prompt = 'prompt'; my $cmd = '/ flow export fcap "src net a.b.c.d " recent'; # my $cmd ='ls'; $telnet = Net::Telnet ->new (Timeout => 20, Host=> $host, Prom +pt => "/$prompt/"); $telnet ->login(Name =>$username, Password => $passwd); @lines = $telnet ->cmd($cmd); $telnet -> close; pop @lines; print @lines;

Cheers Nigel

Edited by Chady -- code tags.


In reply to problem with net::telnet moduleand STDOUT by nigels

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.