set environment variable
Posted in 2008
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi, i note there is not a FGL_SETENV function in traditional Informix
4GL
Anybody has resolved how to set an environment variable (linux, bash)
from 4gl program??
i need:
$ fglgo my4gl
-- my4gl must set MYVAR=SOMEVALUE
$ echo $MYVARSOMEVALUE
Can make this works....
Thanks!
You can't really do that..
You're testing for having set something in the environment from a process
thats been run and finished, and you cant set the environment in a parent
process from a child process.
You can't even do that from a shell script - the closest you can get is
to 'source' the settings so they are read into the current settings. If you
want to take this approach - you might be able to generate a 'settings' file
and then source that, eg :
$ fglgo my4gl# my4gl generates my4gl.env
$ . my4gl.env
$ echo $MYVAR
You should be able to set the environment variables for use within the 4gl
program by calling the C function putenv or setenv (depending on your
platform) - but that will only set it for programs run from the 4gl program
(eg via a RUN command).
Of course - Aubit4GL has a "aclfgl_setenv" to make this easier ;-)
HTH
On Friday 21 November 2008 14:01:34 eferreyra wrote:
> Hi, i note there is not a FGL_SETENV function in traditional Informix
> 4GL
>
> Anybody has resolved how to set an environment variable (linux, bash)
> from 4gl program??
>
> i need:
>
> $ fglgo my4gl>
> -- my4gl must set MYVAR=SOMEVALUE
>
> $ echo $MYVAR> SOMEVALUE
>
> Can make this works....
>
> Thanks!
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
--
Mike Aubury
http://www.aubit.com/
Aubit Computing Ltd is registered in England and Wales, Number: 3112827
Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ
Hi, thanks i do that, anyway the wole process is for set envirnment
variables before an user runs his 4gl menu of programs.
In other program that doenst have ui, i just DISPLAY several
MYVAR=123; export MYVAR
then i call it from a shell:
fglgo my4gl >> /tmp/mktempfile
source /tmp/mktempfile
rm /tmp/mktempfile
But now i need to show a options menu so DISPLAY to console cant help
me :)
thanks again!
On 21 nov, 12:16, Mike Aubury <i...@aubit.com> wrote:
> You can't really do that..
>
> You're testing for having set something in the environment from a process
> thats been run and finished, and you cant set the environment in a parent
> process from a child process.
>
> You can't even do that from a shell script - the closest you can get is
> to 'source' the settings so they are read into the current settings. If you
> want to take this approach - you might be able to generate a 'settings' file
> and then source that, eg :
>
> $ fglgo my4gl> # my4gl generates my4gl.env
>
> $ . my4gl.env
> $ echo $MYVAR>
> You should be able to set the environment variables for use within the 4gl
> program by calling the C function putenv or setenv (depending on your
> platform) - but that will only set it for programs run from the 4gl program
> (eg via a RUN command).
> Of course - Aubit4GL has a "aclfgl_setenv" to make this easier ;-)
>
> HTH
>
> On Friday 21 November 2008 14:01:34 eferreyra wrote:
>
>
>
> > Hi, i note there is not a FGL_SETENV function in traditional Informix
> > 4GL
>
> > Anybody has resolved how to set an environment variable (linux, bash)
> > from 4gl program??
>
> > i need:
>
> > $ fglgo my4gl>
> > -- my4gl must set MYVAR=SOMEVALUE
>
> > $ echo $MYVAR> > SOMEVALUE
>
> > Can make this works....
>
> > Thanks!
> > _______________________________________________
> > Informix-list mailing list
> > Informix-l...@iiug.org
> >http://www.iiug.org/mailman/listinfo/informix-list
>
> --
> Mike Aubury
>
> http://www.aubit.com/
> Aubit Computing Ltd is registered in England and Wales, Number: 3112827
> Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ
Sounds like a job for a 'report' then ;-) On Friday 21 November 2008 14:43:06 eferreyra wrote: > Hi, thanks i do that, anyway the wole process is for set envirnment > variables before an user runs his 4gl menu of programs. > > In other program that doenst have ui, i just DISPLAY several > MYVAR=123; export MYVAR > then i call it from a shell: > > fglgo my4gl >> /tmp/mktempfile > source /tmp/mktempfile > rm /tmp/mktempfile > > But now i need to show a options menu so DISPLAY to console cant help > me :) > > thanks again! > -- Mike Aubury http://www.aubit.com/ Aubit Computing Ltd is registered in England and Wales, Number: 3112827 Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ