Francesco
28th April 2005, 19:46
Why isn't this working?


function extern long setenv(string varname(256), string input.string(1024))
{
string command(1024)

if isspace(input.string) or isspace(varname) then
return(-1)
else

| command = varname & "=""" & input.string & """; export " & varname | sh
command = "export " & varname & "=""" & input.string & """" | ksh/bash
| command = "setenv " & varname & " """ & input.string & """" | csh/tcsh

ret = shell(command, SHELL_BACKGROUND)
| run.prog(command, "", RP_NOWAIT)

if input.string = getenv$(varname) then
return(1)
else
return(-1)
endif
endif
}

mark_h
28th April 2005, 19:56
I think it is because the shell commands starts a shell, sets the variables, then closes the shell. At that point you environment variable is gone. The getenv looks at your current logone environment variables. I can not remember why I played with this once, but I could never figure out how to set a permanent environment variable.

Francesco
28th April 2005, 20:04
That's it. Duh!

I need to pass some variables to a shell script that is kicked off in a function in a different library.
For some reason my external vars from the first function are not being picked up in the other function, so I thought I'd take a short-cut.

Back to the drawing board.

mark_h
28th April 2005, 20:14
You reminded me of what I did - I ended up writing a local file to the users home directory that the next shell script could source and get what it needed.

Francesco
28th April 2005, 20:19
I want a perty solution ;)