Parent don't inherit the child's environment. I'm assuming a Unix-like OS.

\r\n\r\n

Your options IMO are:

\r\n\r\n
    \r\n
  • Have the child report its environment to the parent.
  • \r\n\r\n
  • Determine the child's environment by other means. /proc/pid/env contains this information in Linux.
  • \r\n\r\n
  • Vague possibility: wrap the script in another process which manages it in a way that the environment is determinable. You'd probably have to intercept shell/system calls to do this.
  • \r\n\r\n
  • Make the script do your evil bidding. If it is indeed a shell script, you can modify the startup and/or exit via .bashrc and .bash_logout files. If you can control the effective userid of the script, you may be able to change its startup shell in /etc/passwd. Or you can require modules be run by whomever it is which writes the script. Or intercept the script and modify it prior to submission....
  • \r\n\r\n
\r\n\r\n

HTH