/[pxelator]/lib/PXElator/ssh.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/ssh.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 347 by dpavlin, Thu Aug 27 18:57:46 2009 UTC revision 348 by dpavlin, Sat Aug 29 18:07:49 2009 UTC
# Line 2  package ssh; Line 2  package ssh;
2    
3  use Net::OpenSSH;  use Net::OpenSSH;
4  use English;  use English;
5    use Data::Dump qw/dump/;
6    
7  my $id = 2;  my $id = 2;
8    
# Line 29  sub ethernet_bridge_to { Line 30  sub ethernet_bridge_to {
30    
31  }  }
32    
33    sub shell {
34            my $host = shift;
35    
36            my $ssh = Net::OpenSSH->new( $host );
37    
38            my $html;
39    
40            foreach my $command ( @_ ) {
41                    warn "root\@$host:# $command\n";
42                    my ($out,$err) = $ssh->capture2( $command ) or die "$command ", $ssh->error;
43                    warn "$out\n$err";
44    
45                    $html .= qq|<tt style="color: grey">root\@$host:# <b>$command</b></tt><pre>$out</pre>|;
46                    $html .= qq|<pre style="color: red">$err</pre>| if $err;
47            }
48    
49            return $html;
50    }
51    
52    sub copy_id {
53            my $host = shift;
54            system 'sudo ssh-copy-id -i /root/.ssh/id_rsa.pub root@' . $host;
55    }
56    
57  1;  1;

Legend:
Removed from v.347  
changed lines
  Added in v.348

  ViewVC Help
Powered by ViewVC 1.1.26