Re: modifying environment variables
- Posted by jbrown1050 at yahoo.com Mar 18, 2002
- 353 views
In DOS, you need to modify the environment table yourself. (Someone wrote a library for this i think, but it didn't work for me, so i deleted it.) In Windows, I think there is a setenv() function you can use, but i'm not sure what dll its in. Maybe one of the win32 gurus can help you here. In Linux, try this code: --CUT HERE-- --setenv.eu --sets an env var for Linux --returns 1 on success, 0 on failure --if val = "", then unsets the env var, and returns successfully include dll.e include machine.e constant C_STR = C_POINTER constant setenv_ = define_c_func(open_dll(""), "setenv", {C_STR, C_STR, C_INT}, C_INT) constant unsetenv_ = define_c_proc(open_dll(""), "unsetenv", {C_STR}) global function setenv(sequence name, sequence val) integer ret atom an, av an = allocate_string(name) if length(val) = 0 then c_proc(unsetenv_, {an}) return 1 end if av = allocate_string(val) ret = c_func(setenv_, {an, av, 1}) if ret = 0 then ret = 1 else ret = 0 end if return ret end function --CUT HERE-- On 0, bensler at mail.com wrote: > How can I modify environment variables from within my eu program? > > Using system, or system_exec() seems to open a new instance in order to > set the variables. When the variables are set, the instance is closed, > leaving me with my original environment. > > Chris >