On 7 April 2011 12:33, C.DeRykus <dery...@gmail.com> wrote: > On Apr 7, 2:07 am, paik...@gmail.com (Dermot) wrote: >> On 7 April 2011 00:24, C.DeRykus <dery...@gmail.com> wrote:
>> > On Apr 6, 7:45 am, paik...@gmail.com (Dermot) wrote: >> >> Hello All, >> >> >> I have a issue when I attempt to run a script on one host (B) that is >> >> called by ssh from other host (A). >> >> >> On host B, I have the script in /usr/local/bin/stuff.pl. The script >> >> has the following near the top: >> >> >> use strict; >> >> use warnings; >> >> use lib qw(/etc/perl); >> >> >> use MyApp::Image; >> >> use MyApp::Schema; # Schema will attempt to dbi:SQLite connect to a >> >> local db file. >> >> ... >> >> ... >> >> ... >> >> >> On host A I run a script that does: >> >> >> use FindBin qw($Bin); >> >> use lib qq($Bin/../lib); >> >> ... >> >> ... >> >> ... >> >> my $cmd = qq(ssh -i $Bin/../lib/.ssh/someuser_id.rsa someuser\@) . >> >> $self->config('imageing_server') . >> >> qq( "/usr/local/bin/stuff.pl "); >> >> my $res = qx($cmd); >> >> >> When I run the script, I get: >> >> Can't locate MyApp/Schema.pm in @INC (@INC contains: >> >> /usr/local/bin/../../ /etc/perl >> >> /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi >> >> /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl >> >> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi >> >> /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl >> >> /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) >> >> at /usr/local/bin/stuff.pl line 15. >> >> >> The @INC mentioned in the error looks like the @INC on host A, or at >> >> least perl is looking for the files locally. I fear that, worse than >> >> simply having problem with @INC, other paths, including the path to >> >> local files will try and reference stuff on host A and not host B. >> >> There may be some very good security reasons for this (perldoc >> >> perlsec) but I hoping there is a way to make this work. >> >> >> Does anyone know if or how I can make the script on host B execute >> >> it's commands and look locally for files? >> >> > How's the script on host B invoked... standalone via >> > shebang line or externally as in 'perl stuff.pl'? >> > If the latter, is the invoking perl distro identical with >> > that on the shebang line? >> >> Hi, >> Yes it does. >> >> #!/usr/bin/perl >> >> use Digest::SHA2; >> use DateTime::Format::Strptime; >> use DateTime::Format::SQLite; >> use Getopt::Long; >> >> use strict; >> use warnings; >> use lib qw(/etc/perl); >> >> use MyApp::Image; >> use MyApp::Schema; >> >> The script on host B uses a shebang (!#/usr/bin/perl), the version on >> that host is perl, v5.8.8 built for i386-linux-thread-multi >> >> The perl on host A, the caller, is perl, v5.8.6 built for >> i386-linux-thread-multi. >> >> When I attempt to invoke the script from the command line of host A, I >> get the same error: >> >> [dermot@hosta]$ ssh -i lib/.ssh/someuser_id.rsa someuser@hostb >> "/usr/local/bin/stuff.pl record_number=651500447" >> Can't locate MyApp/Schema.pm in @INC (@INC contains: >> /usr/local/bin/../../ /etc/perl >> /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi >> /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl >> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi >> /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl >> /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) >> at /usr/local/bin/stuff.pl line 15. >> BEGIN failed--compilation aborted at /usr/local/bin/stuff.pl line 15 >> >> user@hostb is not the same user that invokes the script on host A >> >> The big mystery for me is that I have other scripts, albeit that do >> not use MyApp::Schema, that work fine between the two hosts. EG: >> >> ssh -i lib/.ssh/someuser_id.rsa someuser@hostb >> "/usr/local/bin/make_thumbnail.pl --record_number=651500447" >> Can't set owner to 48 on >> /var/media/images/65/15/00/447/651500447-thumb.jpg: Operation not >> permitted >> >> Ok, it has it's issues too but it works locally. So I added the `use >> MyApp::Schema` to the above script and.....dam got the same error: >> > >> /usr/local/bin/../../ /etc/perl >> /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi >> /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl >> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi >> /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl >> /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) >> at /usr/local/bin/make_thumbnail.pl line 11 >> >> Still more baffling is that fact the above script uses MyApp::Image, >> that package only resides on host B. >> >> So I'm a little confused but I think there are enough clues here. Thanks, >> Dermot. > > Ok, that does seem confusing especially since > @INC is host A's rather than B's. For a sanity > check, you might add ssh's verbose switch to > see what's actually occurring: > > my $cmd = > qq(ssh -v -i $Bin/../lib/.ssh/someuser_id.rsa ) > . 'someuser@' > . $self->config('imageing_server') > . '/usr/local/bin/stuff.pl'; > > print "remote cmd: $cmd\n"; # <---- debug > my $res = qx($cmd); > > Also, note, even if you've confirmed that the > MyApp/Schema.pm file actually exists in @INC > on Host B, Perl generates the same error: > > Can't locate MyApp/Schema.pm in @INC ... > > if 'someuser' doesn't have permission to access > the module. So, if 'someuser' doesn't have read > privilege on /etc for instance, you'll get the error. I had thought, last night as I lay in bed thinking about this, that it might be permissions. So I chmod +x the directory. I was just checking that when I noticed this: 6160387 4 drwxr-xr-x 3 root root 4096 Apr 6 13:03 /etc/perl/MyApp/Schema 6160401 4 drwxr-xr-x 2 root root 4096 Apr 6 13:11 /etc/perl/MyApp/Schema/Result 6160403 4 -rwxr-xr-x 1 root root 1467 Apr 6 13:10 /etc/perl/MyApp/Schema/Result/Lowres.pm 6160393 4 -rwxr-xr-x 1 root root 2356 Feb 4 13:30 /etc/perl/MyApp/Image.pm 6160395 12 -rwxr-xr-x 1 root root 12288 Feb 2 11:39 /etc/perl/MyApp/.Image.pm.swp Schema.pm does exist. I feel like a real plum now but hey. Thanks for your help Charles. It focused my mind. Dermot. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/