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: 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/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. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/