Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unix system info in running cobol

Status
Not open for further replies.

Truusvlugindewind

Programmer
Jun 5, 2002
350
0
0
NL
Hi, Using Server Express 2.0.11 on a AiX 4.3.3. box I am looking for a way to obtain the PID of a running cobol program at execution time.
As this information can be retrieved in unix by the command "echo $$", I've tried the following code:

display "$$" upon environment-name
accept WS-pid from environment-value
display " pid " WS-pid

No go: the field WS-pid remains blank.

I know I can obtain like this: "call 'SYSTEM' using 'echo $$ >> /tmp/answer.txt' ".
In my case I want to use the PID info to compose an unique name for the dataset containing the result
(/tmp/$$.txt instead of /tmp/answer.txt).
But how do I know the filename in cobol to open to read the answer?
Or are there other ways to trap STDOUT from a call to 'SYSTEM'?
 
Hi Truus,

i think "display $$ ..." doesn't work, because $$ is a special environment value inside the unix shell. Perhaps it is enough for you to start your program with the PID of the starting shell - something like this:
cobrun yourprog $$

"accept ws-pid from command-line" will do the rest.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top