George,
I'm not sure that I understand your problem. I set an env var in an
interactive i5 session (i.e. QCMD) as follows,
ADDENVVAR ENVVAR(myenvvar) VALUE("test")
I then invoked qp2term using 'call qp2term' and entered 'env' with the
following output under qp2term. As you can see, myenvvar is correctly
set to "test".
_=/QOpenSys/usr/bin/env
LANG=en_US
PASE_LANG=en_US
QIBM_PASE_DESCRIPTOR_STDIO=T
PATH=/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
ROWS=17
QIBM_DESCRIPTOR_STDIN=CRLN=Y
COLUMNS=132
PASE_PATH=/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
LC__FASTMSG=true
LOGNAME=MYUID
LOCPATH=/usr/lib/nls/loc
PASE_LC__FASTMSG=true
QIBM_USE_DESCRIPTOR_STDIO=I
QIBM_IFS_OPEN_MAX=66000
QIBM_PASE_CCSID=819
PASE_SHELL=/QOpenSys/usr/bin/bsh
SHELL=/QOpenSys/usr/bin/sh
PASE_LOCPATH=/usr/lib/nls/loc
HOME=/home/MYUID
PASE_TZ=EST5EDT,M3.2.0,M11.1.0
PASE_NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg/en_US/%N:/usr/lib/nls/msg/en_US/%N.cat
PWD=/home/MYUID
TZ=EST5EDT,M3.2.0,M11.1.0
myenvvar="test"
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg/en_US/%N:/usr/lib/nls/msg/en_US/%N.cat
I then invoked qp2shell using
call qp2shell '/QOpenSys/home/MYUID/ls.sh'
where ls.sh contains
#!/bin/sh
#
set -xv
env > /home/MYUID/envout.txt
and found the following in /home/MYUID/envout.txt.
_=/QOpenSys/usr/bin/env
LANG=en_US
PASE_LANG=en_US
PATH=/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
PASE_PATH=/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
LC__FASTMSG=true
LOGNAME=MYUID
LOCPATH=/usr/lib/nls/loc
PASE_LC__FASTMSG=true
QIBM_IFS_OPEN_MAX=66000
QIBM_PASE_CCSID=819
PASE_LOCPATH=/usr/lib/nls/loc
HOME=/home/MYUID
PASE_TZ=EST5EDT,M3.2.0,M11.1.0
PASE_NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg/en_US/%N:/usr/lib/nls/msg/en_US/%N.cat
PWD=/home/MYUID
TZ=EST5EDT,M3.2.0,M11.1.0
myenvvar="test"
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg/en_US/%N:/usr/lib/nls/msg/en_US/%N.cat
Again, the env var myenvvar correctly contains "test".
Does this help?
Post by George ShawMy apologies. My problem is not with fork(), but with qp2term, qp2shell and
qsh.
fork() propagates environment variables correctly.
If environment variables are created using a .profile file in the home
directory, then these are picked up when starting the interactive shell,
i.e. using the strqsh or qp2term command line, and executing echo.
But if you execute a custom program from the qp2term command line, or
execute the program from the qcmd command line using qsh or qp2shell, then
the custom program does not find the environment variables.
So the problem is how to execute a custom (AIX) program from qcmd, and to
get the program to see environment variables.
Post by George ShawI'm in the process of evaluating the porting of one of our products for
PASE. The AIX code uses fork() to create child processes, but it seems
that
Post by George Shawthe environment variables that are an integral part of the product are not
propagated to the child process.
I've noticed the same problem in qp2term, where a simple program that
prints
Post by George Shawout environment variables shows that they are not propagated from the
qp2term command line to the executed program.
In a related product that is native to the AS/400, we use spawnp() to
create
Post by George Shawprocesses, and this can be configured to propagate environment variables,
so
Post by George Shawpresumably there is not a technical problem with this.
I've not found any documentation that describes how fork() works under
PASE
Post by George Shawin this respect, nor anything that describes an alternative API or
technique
Post by George Shawthat we can use in order to implement this. Can anybody help?