about environment variables and my apps permissions.

I’ve got a two problems with my web app (which is running on OS X)

  1. I shell out to run commands. The commands I run require an environment variable to exist in order to function.
    putting them in my users .profile works, and I can run the command from the terminal but the environment variable isn’t set when I shell out from my application.

  2. The application has to write to a directory that is owned by root. How do I get my application to run ‘as root’?

I found
system.Environment(“MYVAR”)=“foo”
I set my backend to bash
I execute an env and I see that MYVAR is set…
I then run the command that requires the environment variable and it says it’s not set.

Running as root is a bad idea. Is there no way permissions can be setup to allow your app to be run as non-root?

sudo My\ Application does the trick…
but without having the environment variable set running as anyone is pointless…

[quote]1) I shell out to run commands. The commands I run require an environment variable to exist in order to function.
putting them in my users .profile works, and I can run the command from the terminal but the environment variable isn’t set when I shell out from my application.[/quote]
This is standard behavior in every language. System Shell <> Terminal

There are a couple of ways around it:

  1. write a script file and shell.execute it.
  2. use an interactive shell and send whatever commands you need, one at a time.