in reply to Re: Run system command in same context of the script itself
in thread Run system command in same context of the script itself

All the commands run in the parent process. But, I need to set some environment variable in order one of the commands to work. To do that, i use system() call, but it spawns a child process, so the variable it sets, is not vsisble for the parent (which carries all the work). Setting the variable is all the child process does. What i'm trying to do is to set the variable that will allow connection to oracle db. then I wnat to connect to the db and query it. The connection and querying are done in the parent process. I don't quite understand what youre saying there.
  • Comment on Re^2: Run system command in same context of the script itself

Replies are listed 'Best First'.
Re^3: Run system command in same context of the script itself (updated)
by LanX (Saint) on Apr 10, 2023 at 15:03 UTC
    I'm puzzled

    If that's not enough, maybe just better show us an SSCCE of what you want, instead of leaving us the burden of interpretation?

    update

    > All the commands run in the parent process.

    Does that mean Perl is just the sub-process and you want to change the ENV of the non-Perl parent?

    I'm afraid that's not possible, w/o adjusting the parent.

    Already on the OS level this is forbidden for security reasons. The parent-process has full control and must actively change its own ENV. It is protected from changes in a sub-process.

    Simplest solution: -> eval-ing a string returned by the Perl sub-process to set ENV

    But now you are also confronted with security implications, because you have to make sure this communication isn't eavesdropped.

    update

    and if all of this doesn't help, please have a look there -> "I know what I mean. Why don't you?"

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery

Re^3: Run system command in same context of the script itself
by ikegami (Patriarch) on Apr 10, 2023 at 16:35 UTC

    Setting the variable is all the child process does.

    Yes, you are setting one of the child's variable, but that's not the right variable. You want to set one of the parent's variable. I showed one way of doing this.

    I don't quite understand what youre saying there.

    What's unclear?