X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=lib%2FRexec.pm;h=71fdd224da40d6b0ac488004ee8add2d5d4b4c97;hb=4accf346e37b757479d5f1537e71996f5d96a061;hp=bf590724c1e553c8562840b386ef5aa63d02395a;hpb=28c190798ee099c17413fda88e320df4a0e3e78e;p=clearscm.git diff --git a/lib/Rexec.pm b/lib/Rexec.pm index bf59072..71fdd22 100644 --- a/lib/Rexec.pm +++ b/lib/Rexec.pm @@ -160,6 +160,18 @@ our @EXPORT = qw ( my @lines; +sub _debug ($) { + my ($msg) = @_; + + my $logfile = "/tmp/rexex_debug.log"; + + open my $file, '>>', $logfile or die "Unable to open $logfile for writing - $!"; + + print $file "DEBUG: $msg\n"; + + close $file; +} # _debug + sub ssh { my ($self) = shift; @@ -228,12 +240,19 @@ sub ssh { $self->{prompt} = '@@@'; $self->{handle} = $remote; + # OK this is real tricky. If we call execute with a command of PS1=@@@ + # and we've changed our prompt to '@@@' then we'll see the '@@@' in the + # PS1=@@@ statement as the prompt! That'll screw us up so we instead say + # PS1=\@\@\@. The shell then removes the extra backslashes for us and sets + # the prompt to just "@@@" for us. We catch that as our prompt and now we + # have a unique prompt that we can easily recognize. if ($self->{shellstyle} eq 'sh') { - $self->execute ('PS1=@@@'); + $self->execute ('PS1=\@\@\@'); } else { - $self->execute ('set prompt=@@@'); + $self->execute ('set prompt=\@\@\@'); } # if + $self->{handle}->flush; return $remote; } elsif ($timedout) { carp "WARNING: $self->{host} is not responding to $self->{protocol} protocol"; @@ -313,10 +332,16 @@ sub rlogin { $self->{prompt} = '@@@'; $self->{handle} = $remote; + # OK this is real tricky. If we call execute with a command of PS1=@@@ + # and we've changed our prompt to '@@@' then we'll see the '@@@' in the + # PS1=@@@ statement as the prompt! That'll screw us up so we instead say + # PS1=\@\@\@. The shell then removes the extra backslashes for us and sets + # the prompt to just "@@@" for us. We catch that as our prompt and now we + # have a unique prompt that we can easily recognize. if ($self->{shellstyle} eq 'sh') { - $self->execute ('PS1=@@@'); + $self->execute ('PS1=\@\@\@'); } else { - $self->execute ('set prompt=@@@'); + $self->execute ('set prompt=\@\@\@'); } # if return $remote; @@ -412,10 +437,16 @@ sub telnet { $self->{prompt} = '@@@'; $self->{handle} = $remote; + # OK this is real tricky. If we call execute with a command of PS1=@@@ + # and we've changed our prompt to '@@@' then we'll see the '@@@' in the + # PS1=@@@ statement as the prompt! That'll screw us up so we instead say + # PS1=\@\@\@. The shell then removes the extra backslashes for us and sets + # the prompt to just "@@@" for us. We catch that as our prompt and now we + # have a unique prompt that we can easily recognize. if ($self->{shellstyle} eq 'sh') { - $self->execute ('PS1=@@@'); + $self->execute ('PS1=\@\@\@'); } else { - $self->execute ('set prompt=@@@'); + $self->execute ('set prompt=\@\@\@'); } # if return $remote; @@ -708,7 +739,7 @@ retained in the object. Use status method to retrieve it. # Hopefully we will not see the following in the output string my $errno_str = "ReXeCerRoNO="; my $start_str = "StaRT"; - + my $compound_cmd; # If cmd ends in a & then it makes no sense to compose a compound