Initial commit
[clearscm.git] / test / testrexec.pl
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use FindBin;
6
7 use lib "$FindBin::Bin/../lib";
8
9 use Rexec;
10
11 my ($status, $cmd, @output);
12
13 my $hostname = $ENV{HOST}     || 'localhost';
14 my $username = $ENV{USERNAME};
15 my $password = $ENV{PASSWORD};
16
17 my $remote = Rexec->new (
18   host     => $hostname,
19   username => $username,
20   password => $password,
21   timeout  => 30,
22 );
23
24 if ($remote) {
25   print "Connected to $username\@$hostname using "
26       . $remote->{protocol} . " protocol\n";
27     
28   $cmd = "/bin/ls /nonexistent";
29
30   @output = $remote->execute ($cmd);
31   $status = $remote->status;
32
33   print "$cmd status: $status\n";
34
35   $remote->print_lines;
36
37   print "$_\n" foreach ($remote->execute ('cat /etc/passwd'));
38 } else {
39   print "Unable to connect to $username@$hostname\n";
40 } # if
41
42