|
Posted by Dayton Jones on March 2, 2006, 10:51 am
Please log in for more thread options
A. Sinan Unur wrote:
>
> Dayton, *please* do not top-post.
>
>
>>A. Sinan Unur wrote:
>>
>>>
>>>
>>>
>>>>A. Sinan Unur wrote:
>>>>
>>>>
>>>>>
>>>>>
>>>>>
>>>>>>I've got a very simple script (see below) that uses the
>>>>>>File::Remote module. I've set up the script to use ssh/scp
>>>>>>and there is no problem for the user to ssh to the hosts -
>>>>>>but the script fails with a "permission denied" error on the
>>>>>>
>>>>>>>copy command.
>>>>>>
>>>>>>-- begin script
>>>>>>
>>>>>>#!/usr/bin/perl
>>>>>
>>>>>
>>>>>use strict;
>>>>>use warnings;
>>>>>
>>>>>missing.
>>>>>
>>>>>
>>>>>
>>>>>>use File::Remote qw(:replace);
>>>>>>
>>>>>>setrsh('/usr/bin/ssh');
>>>>>>serrcp('/usr/bin/scp');
>>>
>>>^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>...
>>>
>>>
>>>
>>>>I added the strict/warnings but had the same result -- with no extra
>>>>information.
>>>
>>>
>>>Well, did you fix the typo above?
>>>
>>>I don't have File-Remote installed, by I doubt serrcp is correct.
>>
>>Yes, I noticed that when reading your original response -- changed it
>>to "setrcp="
>
>
> Well, apologoies, I misdiagnosed the problem. I looked at the source
> code of File::Remote, and the problem simply is that /dev/null has a
> different name on Windows, i.e. NUL.
>
> The dirty fix would involve replacing File::Remote::_system.
>
> You could also just go in and edit out the 1 > /dev/null out of the
> backticked string. But then, you'd be modifiying a module, and it might
> get overwritten when you upgrade to a new version etc.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use File::Remote qw(:replace);
> use File::Spec::Functions qw( canonpath );
>
> setrsh(canonpath 'C:/opt/cygwin/bin/ssh.exe');
> setrcp(canonpath 'C:/opt/cygwin/bin/scp.exe');
> settmp(canonpath $ENV);
>
> {
> no warnings 'redefine';
> *File::Remote::_system = sub {
> my($self, @cmd) = File::Remote::_self_or_default(@_);
>
> # return "Broken pipe" if cmd invalid
> # chomp(my $return = `@cmd 2>&1 1>/dev/null || echo 32`);
> chomp(my $return = `@cmd 2>&1 1>NUL || echo 32`);
> File::Remote::_debug("_system(@cmd) = $return");
>
> if ($return) {
> # if echo'ed an int (internal tests), use it,
> # else use "Permission denied" (13)
> $return =~ m/^(\d+)$/;
> $! = $1 || 13;
> return undef;
> }
> return 1;
> };
> }
>
> copy('localfile', 'remotefile')
> or die "$\@ = $@\n$! = $!\n";
>
> __END__
>
> Sinan
>
OK, now I'm confused -- I'm not running on a windows platform so the
/dev/null reference is correct. I'm running RedHat EL3 and EL4 -- my
apologies for not specifying that earlier.
|