Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: perl unable to locate my module

by ibm1620 (Monk)
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/'; works! (However, it fails when 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 successfully -- but then it chokes when does 'use;', 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.)

Replies are listed 'Best First'.
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;
    [ "/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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1034830]
and the rats come out to play...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2018-05-21 19:26 GMT
Find Nodes?
    Voting Booth?