From: Jennie 'Seven' Evers-Corvina Date: Mon, 13 Dec 2010 22:18:05 +0000 (-0800) Subject: I've gotten much farther X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=506d80b16e2741746ae37205d2c472a0fdf5e0a7;p=p5sagit%2FIPC-PerlSSH-MultiHop.git I've gotten much farther --- diff --git a/t/scratch.t b/t/scratch.t index 4fa718e..1d51086 100644 --- a/t/scratch.t +++ b/t/scratch.t @@ -30,7 +30,7 @@ use Devel::Dwarn; } sub _build_ssh_env_vars { - return {}; + return ''; # this needs work I think. First off, it won't work. # +{ $_[0]->_firsthop_perlssh->eval(; 'chomp(my @env = `ssh-agent`); my %new_env; foreach (@env) { /^(.*?)=(.*)/; $ENV{$1} =$new_env{$1}=$2; } return %new_env;' ); } } @@ -39,10 +39,10 @@ use Devel::Dwarn; my( $self, @hosts ) = @_; my $ssh = $self->_ssh; - my %vars = %{ $self->_ssh_env_vars }; - my $env_str = ''; $env_str .= "$_='$vars{$_}' " foreach ( keys %vars ); - my $command = join ' ', $env_str, (map "ssh -o StrictHostKeyChecking=no -A $_", @hosts), "perl"; - my( $read, $write ) = $ssh->open2("sh -c $env_str $command"); + my $env_str = $self->_ssh_env_vars; + my $command = join ' ', (map "ssh -o StrictHostKeyChecking=no -A $_", @hosts), "perl"; + $command = "sh -c '$env_str$command'"; + my( $read, $write ) = $ssh->open2($command); my $readfunc = sub { sysread( $read, $_[0], $_[1] ) }; my $writefunc = sub { syswrite( $write, $_[0] ) }; @@ -76,9 +76,9 @@ $perlssh->eval( "use File::HomeDir" ); my $homedir2 = $perlssh->eval( 'File::HomeDir->my_home' ); is( $homedir2, "/home/test", 'got $ENV{HOME} the smart way' ); -my $new_env = $perlssh->eval( 'chomp(my @env = `ssh-agent`); my %new_env; foreach (@env) { /^(.*?)=(.*)/; $ENV{$1} =$new_env{$1}=$2; } my $output; $output .= "$_=$new_env{$_}" foreach ( keys %new_env ); $output;' ); -Dwarn %{ $new_env }; -$perlssh->_ssh_env_vars( %{ $new_env } ); +my $new_env = $perlssh->eval( 'chomp(my @env = `ssh-agent`); my %new_env; foreach (@env) { /^(.*?)=([^;]+)/ or next; $ENV{$1} =$new_env{$1}=$2; } my $output; $output .= "$_=$new_env{$_} " foreach ( keys %new_env ); $output;' ); +Dwarn $new_env; +$pipc->{ssh_env_vars} = $new_env; my @test_hosts = ( 'stagetwo@localhost', 'stagethree@localhost' ); my ($cmd2, $pssh2) = $pipc->_open_perlssh(@test_hosts);