I'm currently trying to write some component tests for my team using python and I ran into a test procedure that tells the tester to source a csh file. This file has a bunch of setenv commands and aliases. All of these environment variables are needed by the next executable in the chain. I wanted to devise some way to extract all of the env vars and pass them to the next process in the chain.
I looked at the following question, which is is almost what I need: Emulating Bash 'source' in Python
It pushes all exported bash environment variables into a dictionary, which I can then pass to the next process. The problem is this seems to only work for export
and not the csh setenv
command.
If this isn't possible, is there a way to run the .csh file with a subprocess command such as /bin/sh -c script.csh
and then run the process that needs those environment variables as a subprocess to that process (so that it could inherit it's environment variables?)
Essentially, I have a process and script that has a bunch of setenv variables and that process needs to run in an environment that contains all of those environment variables.
Thanks for any help,