Professional Web Applications Themes

Remote.pm (File::Remote) problem - PERL Modules

Removed by Administrator...

  1. Moderated Post

    Default Remote.pm (File::Remote) problem

    Removed by Administrator
    Dayton Jones Guest
    Moderated Post

  2. #2

    Default Re: Remote.pm (File::Remote) problem

    Dayton Jones <tkoedgecomcast.net> wrote in
    news:tZKdnQtkzPuPkZjZnZ2dnUVZ_sGdnZ2dcomcast.com:
    > 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');
    *Ah-em*. Have you read the posting guidelines for this group?

    ....
    > Thanks is advance for any help...
    You can learn how to help others help you, and also how to help yourself
    by following the posting guidelines.

    Sinan

    --
    A. Sinan Unur <1usallenroc.ude.invalid>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    [url]http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html[/url]

    A. Sinan Unur Guest

  3. #3

    Default Re: Remote.pm (File::Remote) problem

    Sorry, no I hadn't read the guidelines but I will now.

    I added the strict/warnings but had the same result -- with no extra
    information.

    A. Sinan Unur wrote:
    > Dayton Jones <tkoedgecomcast.net> wrote in
    > news:tZKdnQtkzPuPkZjZnZ2dnUVZ_sGdnZ2dcomcast.com:
    >
    >
    >>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');
    >
    >
    > *Ah-em*. Have you read the posting guidelines for this group?
    >
    > ...
    >
    >
    >>Thanks is advance for any help...
    >
    >
    > You can learn how to help others help you, and also how to help yourself
    > by following the posting guidelines.
    >
    > Sinan
    >
    Dayton Jones Guest

  4. #4

    Default Re: Remote.pm (File::Remote) problem

    Dayton Jones <tkoedgecomcast.net> wrote in
    news:CfOdnXLeZoy5hJjZRVn-uAcomcast.com:
    > A. Sinan Unur wrote:
    >> Dayton Jones <tkoedgecomcast.net> wrote in
    >> news:tZKdnQtkzPuPkZjZnZ2dnUVZ_sGdnZ2dcomcast.com:
    >>
    >>
    >>>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.

    Sinan

    --
    A. Sinan Unur <1usallenroc.ude.invalid>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    [url]http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html[/url]

    A. Sinan Unur Guest

  5. #5

    Default Re: Remote.pm (File::Remote) problem

    Yes, I noticed that when reading your original response -- changed it to
    "setrcp="

    A. Sinan Unur wrote:
    > Dayton Jones <tkoedgecomcast.net> wrote in
    > news:CfOdnXLeZoy5hJjZRVn-uAcomcast.com:
    >
    >
    >>A. Sinan Unur wrote:
    >>
    >>>Dayton Jones <tkoedgecomcast.net> wrote in
    >>>news:tZKdnQtkzPuPkZjZnZ2dnUVZ_sGdnZ2dcomcast.c om:
    >>>
    >>>
    >>>
    >>>>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.
    >
    > Sinan
    >
    Dayton Jones Guest

  6. #6

    Default Re: Remote.pm (File::Remote) problem

    Dayton Jones <tkoedgecomcast.net> wrote in
    news:b7WdnSuPq7BLgZjZnZ2dnUVZ_sadnZ2dcomcast.com:

    Dayton, *please* do not top-post.
    > A. Sinan Unur wrote:
    >> Dayton Jones <tkoedgecomcast.net> wrote in
    >> news:CfOdnXLeZoy5hJjZRVn-uAcomcast.com:
    >>
    >>
    >>>A. Sinan Unur wrote:
    >>>
    >>>>Dayton Jones <tkoedgecomcast.net> wrote in
    >>>>news:tZKdnQtkzPuPkZjZnZ2dnUVZ_sGdnZ2dcomcast. com:
    >>>>
    >>>>
    >>>>> 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{TEMP});

    {
    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

    --
    A. Sinan Unur <1usallenroc.ude.invalid>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    [url]http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html[/url]

    A. Sinan Unur Guest

  7. #7

    Default Re: Remote.pm (File::Remote) problem

    A. Sinan Unur wrote:
    >
    > 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.
    Yeah, Perl is eminently portable - until someone sticks in an
    OS-specific construct. Maybe this is the Unix programmers' revenge for
    all those stupid question marks in web pages made by windows users.
    >
    > 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.
    Another alternative is to contact the creater of the module. If he's
    willing to have his module dependent on File::Spec, he can get the
    correct device name from File::Spec->devnull(), and not have to worry
    about what to call the null device. The File::Spec solution also covers
    VMS, which calls it NLA0:.

    Tom Wyant
    harryfmudd [AT] comcast [DOT] net Guest

  8. #8

    Default Re: Remote.pm (File::Remote) problem

    A. Sinan Unur wrote:
    > Dayton Jones <tkoedgecomcast.net> wrote in
    > news:b7WdnSuPq7BLgZjZnZ2dnUVZ_sadnZ2dcomcast.com:
    >
    > Dayton, *please* do not top-post.
    >
    >
    >>A. Sinan Unur wrote:
    >>
    >>>Dayton Jones <tkoedgecomcast.net> wrote in
    >>>news:CfOdnXLeZoy5hJjZRVn-uAcomcast.com:
    >>>
    >>>
    >>>
    >>>>A. Sinan Unur wrote:
    >>>>
    >>>>
    >>>>>Dayton Jones <tkoedgecomcast.net> wrote in
    >>>>>news:tZKdnQtkzPuPkZjZnZ2dnUVZ_sGdnZ2dcomcast .com:
    >>>>>
    >>>>>
    >>>>>
    >>>>>>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{TEMP});
    >
    > {
    > 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.
    Dayton Jones Guest

  9. #9

    Default Re: Remote.pm (File::Remote) problem

    Dayton Jones <tkoedgecomcast.net> wrote in news:4N-dnaBMS9EUiZrZRVn-
    [email]ogcomcast.com[/email]:
    > A. Sinan Unur wrote:
    ....
    >>>>>A. Sinan Unur wrote:
    >>>>>
    >>>>>
    >>>>>>Dayton Jones <tkoedgecomcast.net> wrote in
    >>>>>>news:tZKdnQtkzPuPkZjZnZ2dnUVZ_sGdnZ2dcomcas t.com:
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>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.
    ....
    >>>>>>>use File::Remote qw(:replace);
    >>>>>>>
    >>>>>>>setrsh('/usr/bin/ssh');
    >>>>>>>serrcp('/usr/bin/scp');
    >>>>
    >>>>^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >>>>...
    >>>>
    ....
    >> 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.
    ....
    > 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.
    Please trim your replies a bit. I don't think I did a good job after so
    many repeated full quotes.

    Upon looking at File::Remote again, I noticed that there is another
    potential bug in File::Remote::_system:

    sub _system {
    my($self, cmd) = _self_or_default(_);

    # return "Broken pipe" if cmd invalid
    chomp(my $return = `cmd 2>&1 1>/dev/null || echo 32`);
    _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;

    Notice how $! is set without checking if the match above succeeded? That
    might cause this routine to report an error when there was none if $1
    had been set earlier.

    Are you sure the file was not copied?

    Another idea is to temporarily enable debugging by setting $DEBUG = 1
    aorund line 114 of the module:

    # Simple debugging function
    my $DEBUG = 1;
    sub _debug { warn "debug: ", _ if $DEBUG };

    See what you get in the actual trace.


    Sinan
    --
    A. Sinan Unur <1usallenroc.ude.invalid>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    [url]http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html[/url]

    A. Sinan Unur Guest

  10. #10

    Default Re: Remote.pm (File::Remote) problem

    A. Sinan Unur wrote:
    > Upon looking at File::Remote again, I noticed that there is another
    > potential bug in File::Remote::_system:
    >
    > sub _system {
    > my($self, cmd) = _self_or_default(_);
    >
    > # return "Broken pipe" if cmd invalid
    > chomp(my $return = `cmd 2>&1 1>/dev/null || echo 32`);
    > _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;
    >
    > Notice how $! is set without checking if the match above succeeded? That
    > might cause this routine to report an error when there was none if $1
    > had been set earlier.
    >
    > Are you sure the file was not copied?
    >
    > Another idea is to temporarily enable debugging by setting $DEBUG = 1
    > aorund line 114 of the module:
    >
    > # Simple debugging function
    > my $DEBUG = 1;
    > sub _debug { warn "debug: ", _ if $DEBUG };
    >
    > See what you get in the actual trace.
    >
    >
    > Sinan


    Well, enabling debug basically looks like it's pointing the finger at
    ssh/scp :

    debug: copy -- system(File::Remote=HASH(0x9bd55b4)->setrcp,
    host1:/tmp/file, host1:/tmp/file2) at
    /usr/lib/perl5/site_perl/5.8.5/File/Remote.pm line 115.
    debug: _system(/usr/bin/scp host1:/tmp/file host1:/tmp/file2) = Host key
    verification failed.
    lost connection
    32 at /usr/lib/perl5/site_perl/5.8.5/File/Remote.pm line 115.
    host1 :: Permission denied


    So even though, as that user I can ssh/scp to host1 with no problems,
    the module can't pass the host verification stage...
    Dayton Jones Guest

Similar Threads

  1. Replies: 0
    Last Post: November 27th, 09:13 AM
  2. FTP file from Local to Remote
    By dlcmpls in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: May 23rd, 05:23 PM
  3. How to get a remote file listing in PHP
    By Daniel Hofmann in forum PHP Development
    Replies: 1
    Last Post: November 13th, 03:25 PM
  4. remote file edit
    By xEM in forum PHP Development
    Replies: 4
    Last Post: October 20th, 06:09 PM
  5. Setting folder permissions on remote machine / remote domain
    By Tim Chandler in forum ASP.NET Security
    Replies: 0
    Last Post: October 7th, 04:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139