Re: pass enviornment variables to popen
From: wally (root_at_localhost.localdomain)
Date: 01/30/05
- Next message: Patrick TJ McPhee: "Re: pass enviornment variables to popen"
- Previous message: read_the_signature_at_null.com: "Re: pass enviornment variables to popen"
- In reply to: sam: "pass enviornment variables to popen"
- Next in thread: wally: "Re: pass enviornment variables to popen"
- Reply: wally: "Re: pass enviornment variables to popen"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 12:20:19 -0500
sam wrote:
> Hi,
>
> How can I pass enviornment variables to popen() in C?
> I want to do something like this:
> setenv("KEY_CONF", "/usr/local/etc/ssl/conf/openssl.conf", 1);
> popen("openssl <some commandline args> $KEY_CONF", "w");
>
> But the above enviornment variable get removed in calling popen().
> Unless I rewrite popen(), I don't see I can pass the enviornment
> variables to popen().
>
>
> Sam.
why not try something along the lines of:
setenv("KEY_CONF", "/usr/local/etc/ssl/conf/openssl.conf", 1);
...
char *key_conf=getenv("KEY_CONF");
char pipe_command[255];
//although you should probably restrict the size of that array to avoid out
//of bounds in case the KEY_CONF is set to something so big that it wont fit
//here so you can try something along the lines of:
//*pipe_command=malloc(sizeof("openssl <some commandline args> ") + sizeof
(&key_conf));
sprintf(pipe_command("openssl <some commandline args> %s", pipe_command);
pipe_fp=popen(pipe_command, "w");
-- WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tommorow?" BSD: "Are you guys coming or what?"
- Next message: Patrick TJ McPhee: "Re: pass enviornment variables to popen"
- Previous message: read_the_signature_at_null.com: "Re: pass enviornment variables to popen"
- In reply to: sam: "pass enviornment variables to popen"
- Next in thread: wally: "Re: pass enviornment variables to popen"
- Reply: wally: "Re: pass enviornment variables to popen"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|