Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

remote readdir

by deprecated (Priest)
on Aug 23, 2001 at 21:24 UTC ( #107414=snippet: print w/replies, xml ) Need Help??
Description: Sure, it's an ugly hack. It's even downright insecure. But its pretty darn cool to be able to readdir on remote machines.
# telnet readdir replacement
sub treaddir {
  # return an array of files/dirs from a remote host like readdir
  # using Net::Telnet
  my ($host, $user, $pass, $dir) = (@_);
  my $rhost = new Net::Telnet (Timeout => 10) or die "Net::Telnet coul
+d not connect to $host\n";
  $rhost -> open( $host );
  $rhost -> login( $user, $pass );
  # yes its a kludge. its the last element of ls -la
  my @filesdirs = map { (split m[\s+], $_)[8] } $rhost -> cmd(qq{ ls -
+la $dir });
  chomp @filesdirs;
  $rhost -> close();
  return @filesdirs;
}
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: snippet [id://107414]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2023-05-30 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?