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;
}
|