Author |
Message
|
gopalsamant |
Posted: Mon Nov 22, 2004 6:57 pm Post subject: Using getenv for key repo path |
|
|
Novice
Joined: 24 Sep 2004 Posts: 17
|
Hi all, i am facing a problem reading the unix enviornment variable. actually my mq program is in C and i am setting the key repo path in the profile file. but when i read the varaible set in profile file using getenv function i get blank. but setnev is working fine. Can some guide me with what could be the issue. below is the syntax in profile file and in the C client program.
profile file:
MQKEYREPO=/cq1/bin/ssl/key; export MQKEYREPO
C client program :
strcpy(ls_KeyRepo,(char *)getenv( "MQKEYREPO" ));
strcpy(sco.KeyRepository, ls_KeyRepo ) ; |
|
Back to top |
|
 |
kirani |
Posted: Mon Nov 22, 2004 11:31 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Do you see the env variable set when you logon to the box?
Try printing the env variable within your program after getenv function. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
gopalsamant |
Posted: Mon Nov 22, 2004 11:34 pm Post subject: |
|
|
Novice
Joined: 24 Sep 2004 Posts: 17
|
If i do a echo on unix box then i do get the value. but when i print it after reading it in the C progam it comes out to be blank. i guees the execution of this c program is opening another shell or something like that i dont know exactly what. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Nov 23, 2004 6:02 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
If the environment variable is not visible to your program, it's either because your program cleared the environment, or because your program was not started in the environment you think it was.
Let's go with the later possibility, since it's significantly more likely.
How are you starting this program? From the prompt? From cron or similar? From initd or similar? From triggering? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
gopalsamant |
Posted: Tue Nov 23, 2004 6:44 pm Post subject: |
|
|
Novice
Joined: 24 Sep 2004 Posts: 17
|
Actaully here is what we are doing
cc -c test.c -o test.o
ld -o /cq1/bin/test.so test.o -G -bnoentry -bexpall -lmqic -lc
in sql
drop library test_lib ;
create or replace LIBRARY test_lib is '/cq1/bin/test.so';
create or replace procedure test_1(param)
as external
name "test1"
library test_lib
language C
parameters ( params);
then programatically we are calling this procedure for MQ which give error 2381 which is key repo not found and seeing the logfile show the varaible i have explained in the start of the issue is returning null. |
|
Back to top |
|
 |
|