Thank you for everyones remarks. Further investigation found that the Telnet module needs to read in blocks when trying to populate a local variable...Should have researched this a little further before posting. Thanks again.
## Make sure prompt won't match anything in send data. $prompt = "_funkyPrompt_"; $host->prompt("/$prompt\$/"); $host->cmd("set prompt = '$prompt'"); ## Get size of file. ($line) = $host->cmd("/bin/ls -l $filename"); ($size_bsd, $size_sysv) = (split ' ', $line)[3,4]; if ($size_sysv =~ /^\d+$/) { $size = $size_sysv; } elsif ($size_bsd =~ /^\d+$/) { $size = $size_bsd; } else { die "$filename: no such file on $hostname"; } ## Start sending the file. binmode STDOUT; $host->binmode(1); $host->print("/bin/sh -c 'stty raw; cat $filename'"); $host->getline; # discard echoed back line ## Read file a block at a time. $num_read = 0; $prevblock = ""; $start_time = time; while (($block = $host->get) and $block !~ /$prompt$/o)) { if (length $block >= length $prompt) { print $prevblock; $num_read += length $prevblock; $prevblock = $block; } else { $prevblock .= $block; } } $host->close; ## Print last block without trailing prompt. $prevblock .= $block; $prevblock =~ s/$prompt$//; print $prevblock; $num_read += length $prevblock; die "error: expected size $size, received size $num_read\n" unless $num_read == $size; ## Print totals. $total_time = (time - $start_time) || 1; $k_per_sec = ($size / 1024) / $total_time; $k_per_sec = sprintf "%3.1f", $k_per_sec; warn("$num_read bytes received in $total_time seconds ", "($k_per_sec Kbytes/s)\n");

Edited by planetscape - added code tags


In reply to Re^2: unix cat by jdelmedico
in thread unix cat by jdelmedico

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.