-   Programming (
-   -   executing a shell script from C (

llama_meme 04-01-2002 10:30 AM

executing a shell script from C
bit of an obscure question, but here goes...
is there any way of executing a shell script inside a C program, and then accessing the enviroment of that shell script using getenv()?

e.g., if i had the script


could i execute it within my program and then find the value assigned to variable?


kwigibo 04-01-2002 08:37 PM

i know you can execute programs with the call

system(char *)

so considering shell scripts have xcutable permission you could go along that line. I really don't know if this is what your after or not though.


crabboy 04-01-2002 09:10 PM

I think if you export the vars in the shell that you create it may work, but I've never done it that way. Unless you are really stuck on using the env vars, I'd suggest that you use popen and get the output of the script via a pipe.

All times are GMT -5. The time now is 09:16 AM.