Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > embedded perl path $ENV{PATH} problem

Reply
Thread Tools

embedded perl path $ENV{PATH} problem

 
 
R. Sherwin Kartick
Guest
Posts: n/a
 
      09-22-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded <divs> with events: How to prevent the parent div's eventfrom being fired when the embedded div's event is fired? Num GG Javascript 2 11-17-2008 08:56 PM
Embedded vs. Non-embedded Tests Trans Ruby 11 09-05-2007 11:22 AM
Embedded languages based on early Ada (from "Re: Preferred OS, processor family for running embedded Ada?") Colin Paul Gloster VHDL 48 04-10-2007 10:31 AM
How to display images embedded in e-mail as embedded, not attachments Jim Firefox 4 12-11-2004 05:36 AM
Databind an embedded control in an embedded datagrid Thomas Dodds ASP .Net Datagrid Control 0 07-26-2004 08:20 PM



Advertisments