Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: perl unable to locate my module

by ibm1620 (Beadle)
on May 22, 2013 at 23:50 UTC ( #1034830=note: print w/ replies, xml ) Need Help??


in reply to perl unable to locate my module

Here's where things stand, taking into account various people's suggestions:

I moved the module to /internal/charrison/. Every directory from root on down is 0777. Still same problems.

require '/internal/charrison/IPC.pm'; works! (However, it fails when IPC.pm issues 'use WDI;')

When clhtest (normally invoked by xinetd) is invoked from command line, it works fine, fork/exec'ing 'test'.

I think I am having some issues with the Perl 'exec' statement (whose documentation I frankly can't fathom). When I write

$command = q{/usr/bin/perl}; @arglist = q{-I /internal/charrison /internal/charrison/test -l /inter +nal/charrison -P /internal/charrison}; exec $command @arglist;
It fails in the usual manner. But when I write
exec "$command @arglist";
it *does* load IPC.pm successfully -- but then it chokes when IPC.pm does 'use WDI.pm;', like above. At this point I wonder if there's something wrong with the command string I'm passing to exec. (I now realize there are several different ways of giving paramenters to exec(), but I don't understand them, so I should probably stick to the single-argument model.)


Comment on Re: perl unable to locate my module
Select or Download Code
Re^2: perl unable to locate my module
by Anonymous Monk on May 23, 2013 at 07:04 UTC
    Um, try
    @perl = qw{ /usr/bin/perl -I /internal/charrison }; @program = qw{ /internal/charrison/test }; @args = qw{ -l /internal/charrison -P /internal/charrison }; @cmd = ( @perl, @program, @args ); use Data::Dump; dd( \@cmd ); exec @cmd;
    cause
    [ "/usr/bin/perl", "-I", "/internal/charrison", "/internal/charrison/test", "-l", "/internal/charrison", "-P", "/internal/charrison", ]

    This avoids the shell.

      That seems to have solved the problem. I don't understand how avoiding the shell made any difference, since from what I can make of the exec() doc, involving the shell mainly allows metacharacters to be interpreted.

      However, based on your solution, it appears that the safest way to pass multiple arguments to exec() is in an array of "words" (as defined by qw//).

      Thank you for your help!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1034830]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2014-07-28 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (196 votes), past polls