7 use lib "$FindBin::Bin/../lib";
11 my ($status, $cmd, @output);
13 my $hostname = $ENV{HOST} || 'localhost';
14 my $username = $ENV{USERNAME};
15 my $password = $ENV{PASSWORD};
17 my $command = $ENV{COMMAND};
20 $command = join ' ', @ARGV;
22 $command = 'ls /tmp' unless $command;
25 print "Attempting to connect to $username\@$hostname to execute \"$command\"\n";
27 my $remote = Rexec->new (
29 username => $username,
30 password => $password,
35 print "Connected to $username\@$hostname using "
36 . $remote->{protocol} . " protocol\n";
38 print "Executing command \"$command\" on $hostname as $username\n";
39 @output = $remote->execute ($command);
40 $status = $remote->status;
42 print "\"$command\" status: $status\n";
45 print "No lines of output received!\n";
47 print "$_\n" foreach (@output);
50 print "Unable to connect to $username@$hostname\n";