output of a remote telnet command

M

mike

hi
i have a perl listing like this

$command = qq(perl -e 'while ( </tmp/*.txt> ) { print STDOUT $_ if -s ; }' );
my $telnet = Net::Telnet-> new
(
Timeout => 30,
Host=> server
);
$telnet-> login($name, $pass);
@listing = $telnet-> cmd("$command");
$telnet->close;
print @listing;

the output of @listing gives me
/tmp/test.txt/tmp/test2.txtserver

how can i make it append a newline such that
/tmp/test.txt
/tmp/test2.txt
server

i tried to change my $command to
$command = qq(perl -e 'while ( </tmp/*.txt> ) { print STDOUT "$_\n" if -s ; }' )

but the @listing gives me

" if -s ; }'


thanks for any help
 
W

Walter Roberson

:i have a perl listing like this

:$command = qq(perl -e 'while ( </tmp/*.txt> ) { print STDOUT $_ if -s ; }' );
:my $telnet = Net::Telnet-> new
: (
: Timeout => 30,
: Host=> server
: );
: $telnet-> login($name, $pass);
: @listing = $telnet-> cmd("$command");
: $telnet->close;
:print @listing;

:the output of @listing gives me
:/tmp/test.txt/tmp/test2.txtserver

:how can i make it append a newline such that
:/tmp/test.txt
:/tmp/test2.txt
:server

Two ways:

print join( "\n", @listing ), "\n";

Or

{
local( $" = "\n" );
print @listing, "\n";
}
 
P

Paul Lalli

:the output of @listing gives me
:/tmp/test.txt/tmp/test2.txtserver

:how can i make it append a newline such that
:/tmp/test.txt
:/tmp/test2.txt
:server

{
local( $" = "\n" );
print @listing, "\n";
}

Correction - $" will not affect the printing of @listing in that example.
Either change $" to $, or change the print statement to
print "@listing\n";

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,082
Members
48,773
Latest member
Kaybee

Latest Threads

Top