1748195 Members
2726 Online
108759 Solutions
New Discussion юеВ

Re: LIB$SPAWN

 
Sk Noorul  Hassan
Regular Advisor

LIB$SPAWN

Hi,
I am trying to execute one dcl script in a program using lib$spawn. It seems the program is not executing the script as I am not getting the required result. Is it possible to know, if the script has been successfully executed at DCL prompt or not ?
28 REPLIES 28
Volker Halle
Honored Contributor

Re: LIB$SPAWN

Hi,

do you check the system service status return value from the LIB$SPAWN call ?

Do you use the COMPLETION_STATUS parameter ? It will receive the exit status of the spawned subprocess.

You can also check with accounting, whether the subprocess has been created at all and what it's exit status is.

Volker.
Wim Van den Wyngaert
Honored Contributor

Re: LIB$SPAWN

And finally you can do @script/out=xxx
to capture the result, if any.

Wim
Wim
Sk Noorul  Hassan
Regular Advisor

Re: LIB$SPAWN

Volker,
Can you write few lines how to get the completion status in a program, I am using the following line inside program

lib$spawn('@path:xx.com');
Volker Halle
Honored Contributor

Re: LIB$SPAWN

There should be a C example program in SYS$EXAMPLES, which includes a fully coded LIB$SPAWN invocation in C:

SYS$COMMON:[SYSHLP.EXAMPLES]ALPHA_LOGGER.C

status = LIB$SPAWN(0, &devnam, &devnam, &flags, 0, &pid, 0, 0,
subprocess_exit, 0);
if (status & SS$_NORMAL)


Volker.
Sk Noorul  Hassan
Regular Advisor

Re: LIB$SPAWN

Volker,

Now after putting status check, I could found that lib$spawn is returning not sucess value i.e. DCL script is not executing. Can u guide me why this is not executing ??
Volker Halle
Honored Contributor

Re: LIB$SPAWN

You need to print both the STATUS value as returned from the LIB$SPAWN call (and the COMPLETION_STATUS, IF LIB$SPAWN returned with SS$_NORMAL).

Then use that value and translate it to the appropriate error message:

$ WRITE SYS$OUTPUT F$MESSAGE(value)
or
$ EXIT value

Make sure you use the correct radix (hex or decimal) depending on your printf format statement.

Volker.
Sk Noorul  Hassan
Regular Advisor

Re: LIB$SPAWN

Hi, when I am trying to run this program

run/proc= program_name/output=err.txt program

I am getting 'no CLI present to perform function' error in the file err.txt

pls suggest
Volker Halle
Honored Contributor

Re: LIB$SPAWN

When you run your program in a SUB-process without DCL, there is no CLI to process a LIB$SPAWN...

It should work, if you run your program straight in your process with: $ RUN PROGRAM

Volker.
Sk Noorul  Hassan
Regular Advisor

Re: LIB$SPAWN

Hi,

When I am running the program using "RUN prog_name", it is executing my DCL script and is not releasing the terminal. But when I am putting in detached mode, it is not executing my DCL script.

Pls suggest