embedded perl path $ENV{PATH} problem

Discussion in 'Perl Misc' started by R. Sherwin Kartick, Sep 22, 2004.

  1. I have embedded perl in my c program, however I have encountered a
    problem where the $ENV{PATH} can only be updated in the first
    PerlInterpreter instance.
    I get "unable to start foo.sh: No such file or directory at -e line
    2." It appears perl is not using the updated PATH.

    I am using perl 5.8.0, compile-time options: DEBUGGING MULTIPLICITY
    USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT on Red Hat
    Enterprise Linux WS release 3 (Taroon Update 1).

    The following is from the docs with modifications to show the problem:

    #include <EXTERN.h>
    #include <perl.h>

    #define SAY_HELLOA "-e", "print qq(Hi, A I'm $^X\n)"
    #define SAY_HELLOB "-e", "print qq(Hi, B I'm $^X\n); $ENV{PATH} .=
    \":/home/username/foo\"; open(FOO, \"foo.sh |\") or die \"unable to
    start foo.sh: $!\"; close FOO;"
    int main(int argc, char **argv, char **env)
    {
    PerlInterpreter
    *one_perl = perl_alloc(),
    *two_perl = perl_alloc();
    char *one_args[] = { "one_perl", SAY_HELLOA };
    char *two_args[] = { "two_perl", SAY_HELLOB};
    PERL_SET_CONTEXT(one_perl);
    perl_construct(one_perl);
    PERL_SET_CONTEXT(two_perl);
    perl_construct(two_perl);
    PERL_SET_CONTEXT(one_perl);
    perl_parse(one_perl, NULL, 3, one_args, (char **)NULL);
    PERL_SET_CONTEXT(two_perl);
    perl_parse(two_perl, NULL, 3, two_args, (char **)NULL);
    PERL_SET_CONTEXT(one_perl);
    perl_run(one_perl);
    PERL_SET_CONTEXT(two_perl);
    perl_run(two_perl);
    PERL_SET_CONTEXT(one_perl);
    perl_destruct(one_perl);
    PERL_SET_CONTEXT(two_perl);
    perl_destruct(two_perl);
    PERL_SET_CONTEXT(one_perl);
    perl_free(one_perl);
    PERL_SET_CONTEXT(two_perl);
    perl_free(two_perl);
    }


    This program will fail, yes foo.sh exists and it is not in my initial
    path. However, if you run SAY_HELLOB in the the first interpreter
    everything will work!

    char *one_args[] = { "one_perl", SAY_HELLOB };
    char *two_args[] = { "two_perl", SAY_HELLOA};

    Any ideas, suggestions. I have tried this on win32 and it works fine.

    thanks ... sherwin
     
    R. Sherwin Kartick, Sep 22, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    345
    Thomas Hawtin
    Aug 9, 2005
  2. Ankit Mehta
    Replies:
    1
    Views:
    1,442
    Simon Brooke
    Sep 29, 2006
  3. Ken Innes
    Replies:
    4
    Views:
    153
    Eric Hodel
    Nov 10, 2004
  4. Rube N00b

    Ruby settings, path/env/lib etc.

    Rube N00b, Jul 24, 2006, in forum: Ruby
    Replies:
    1
    Views:
    85
  5. TDR
    Replies:
    3
    Views:
    180
    Daniel Berger
    Aug 31, 2007
Loading...

Share This Page