lua-users home
lua-l archive

Re: How do I change Environment variables

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 1/29/07, Robert Raschke <rrlua@tombob.com> wrote:
For what it's worth, here's how I do putenv() on Windows:
int
lputenv(lua_State *L)
{
 int n = lua_gettop(L); /* number of arguments */
 if (n != 1) {
 lua_pushstring(L, "wrong number of arguments to function `putenv'");
 lua_error(L);
 } else {
 if (_putenv(lua_tostring(L, 1)) != 0) {
 lua_pushstring(L, "calling function `putenv' failed");
 lua_error(L);
 }
 }
 return 0;
}
And then add
 lua_register(L, "putenv", lputenv);
after creating your Lua state and before invoking your Lua program.
And use it like
 putenv "env_var=value"
Thanks. That is a great example. I will use it later.
--
Regards,
Ryan
RJP Computing

AltStyle によって変換されたページ (->オリジナル) /