Computing.Net > Forums > Unix > SCP FAILING in PERL Application

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

SCP FAILING in PERL Application

Reply to Message Icon

Original Message
Name: raj_now
Date: February 11, 2005 at 13:08:18 Pacific
Subject: SCP FAILING in PERL Application
OS: SunOS Release 5.6 Version
CPU/Ram: spac
Comment:

Will appreciate any help with my question:
I am using a Perl application to do SCP a file to a remote machine.
Its failing with 'PerlRun: open3: exec of scp -pqB ... failed at ..5.6.0/Net/SCP.pm line 93.
When I see line 93 its the scp command of scp the source to the destination
" @cmd = ( $scp, $flags, $src, $dest );"

Below is the subroutine thas is failing the above line is marked with >>>> in the submodules :
sub scp {
my $self = ref($_[0]) ? shift : {};
my($src, $dest, $interact) = @_;
my $flags = '-p';
$flags .= 'r' unless &_islocal($src) && ! -d $src;
my @cmd;
if ( ( defined($interact) && $interact )
|| ( defined($self->{interact}) && $self->{interact} ) ) {
@cmd = ( $scp, $flags, $src, $dest );
print join(' ', @cmd), "\n";
unless ( &_yesno ) {
$self->{errstr} = "User declined";
return 0;
}
} else {
$flags .= 'qB';
>>>>>> @cmd = ( $scp, $flags, $src, $dest );
}
my($reader, $writer, $error ) =
( new IO::Handle, new IO::Handle, new IO::Handle );
$writer->autoflush(1);# $error->autoflush(1);
my $pid = open3($writer, $reader, $error, @cmd );
waitpid $pid, 0;
if ( $? >> 8 ) {
my $errstr = join('', <$error>);
#chomp(my $errstr = <$error>);
$self->{errstr} = $errstr;
0;
} else {
1;
}
}



Report Offensive Message For Removal


Response Number 1
Name: FishMonger
Date: February 12, 2005 at 23:18:25 Pacific
Reply: (edit)

I don't see anything wrong with the line you pointed out; I think it's in the open3 call. Also, I don't see the need to have the 2 identical assignments to @cmd.

See if this helps:

my @cmd = ( $scp, $flags, $src, $dest );

if ( ( defined($interact) && $interact ) || ( defined($self->{interact}) && $self->{interact} ) ) {
print join(' ', @cmd), "\n"; # is this a debugging line?
unless ( &_yesno ) {
$self->{errstr} = "User declined";
return 0;
}
} else {
$flags .= 'qB';
}

my($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle );
$writer->autoflush(1);# $error->autoflush(1);

my $cmd = join(' ', @cmd);
my $pid = open3(\$writer, \$reader, \$error, $cmd );


Report Offensive Follow Up For Removal

Response Number 2
Name: FishMonger
Date: February 12, 2005 at 23:24:48 Pacific
Reply: (edit)

Also, look at the differences and simularities between:

print join(' ', @cmd), "\n";
print "@cmd" . $/;
print @cmd . $/; # $/ == "\n"


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History




Data Recovery Software