Re: Setting env vars from Cocoa with /bin/sh?
Re: Setting env vars from Cocoa with /bin/sh?
- Subject: Re: Setting env vars from Cocoa with /bin/sh?
- From: Kaelin Colclasure <email@hidden>
- Date: Fri, 9 Apr 2004 06:59:23 -0700
On Apr 8, 2004, at 6:11 PM, David Piasecki wrote:
>
I figured out how to set my environment variables from the terminal
>
window with /bin/sh, but it doesn't seem to accept the same commands
>
from my Cocoa program.
>
>
I'm trying to do VAR=/Path/To/Whatever
>
>
Any ideas how to do this from the confines of Cocoa and
>
Objective-C/C++?
If you want to stick with system(3) then one option is to write a shell
script that sets up the environment that you want and then execs your
executable. You can then use system to execute the script.
Alternatively, you can use fork(2) and execle(3) or exect(3) rather
than calling system. This gives you complete control over the child
processes' environment.
HTH,
-- Kaelin
>
David
>
>
>
>
On Apr 8, 2004, at 5:35 PM, David Piasecki wrote:
>
>
> I'm using the system(char *cmd) call to execute commands from within
>
> my application; however, I need certain environment variables set.
>
> The shell that runs is /bin/sh, which lacks all my environment
>
> variable settings I have with tcsh and bash. I've only ever set env
>
> variables with tcsh or bash or other shells that use setenv or
>
> export. These commands are shell-specific and unavailable to /bin/sh.
>
> There must be a way of setting an environment variable with /bin/sh.
>
> Does anyone know?
>
>
>
> David
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.