cancel
Showing results for 
Search instead for 
Did you mean: 

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
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
Jan van den Ende
Honored Contributor

Re: LIB$SPAWN

Sk,

if you want to execute DCL in a dtetached process (or spawned from such, as you are trying), then use
$ RUN SYS$SYSTEM:LOGINOUT.EXE/INPUT=/OUTPUT=
This gives your process the CLI, which means, enables DCL.

HTH

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Robert_Boyd
Respected Contributor

Re: LIB$SPAWN

Instead of

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

Create a command procedure such as

run_program_name.com

Then you can use this command:

run/proc= program_name/output=err.txt /input=disk:[dir]run_program_name.com sys$system:loginout/authorize

This will create a complete DCL environment, including running the LOGIN.COM of the username the command is run under.

Robert
Master you were right about 1 thing -- the negotiations were SHORT!
Robert_Boyd
Respected Contributor

Re: LIB$SPAWN

Ha! Jan, you and I must have been typing the same solution at the same time!

Proost!

Robert
Master you were right about 1 thing -- the negotiations were SHORT!
Sk Noorul Hassan
Regular Advisor

Re: LIB$SPAWN

Hi,
I am trying to execute my DCL script using LIB$SPAWN inside a PASCAL program to create & enable a device on a terminal server port.

This script has to run along with the PASCAL code.
John Gillings
Honored Contributor

Re: LIB$SPAWN


>LIB$SPAWN inside a PASCAL program to
>create & enable a device on a terminal
>server port.

Why not create and enable the terminal server port directly from your program? See I/O Users Guide, Chapter Terminal Driver, in particular example 5-1 in Section 5.6.

http://h71000.www7.hp.com/doc/82FINAL/aa-pv6sg-tk/aa-pv6sg-tk.PDF

For further assistance, please log a case with your local customer support centre.
A crucible of informative mistakes
Sk Noorul Hassan
Regular Advisor

Re: LIB$SPAWN

Hi, Is it possible to use lib$do_command in this case, inside my pascal program.If yes, what environement definition is required for this.
Pls suggest
Hein van den Heuvel
Honored Contributor

Re: LIB$SPAWN


Yes, you can use LIB$DO_COMMAND, but that work a little like the Unix 'exec' and conflicts with your requirement "This script has to run along with the PASCAL code."

As per online doc:

LIB$DO_COMMAND
Execute Command
The Execute Command routine stops program execution and directs the command language interpreter (CLI) to execute a command that you supply as the argument. If successful, LIB$DO_COMMAND does not return control to the calling program. Instead, LIB$DO_COMMAND begins execution of the specified command.

If you want control to return to the caller, use LIB$SPAWN instead.


fwiw.
Hein.
Jan van den Ende
Honored Contributor

Re: LIB$SPAWN

Sk,

LIB$DO_COMMAND -- transfers -- control to the named procedure, and EXITs your image.
That means, it is THE LAST statement in your programm that gets executed.
As far as I understand you so far, that is NOT what you try to achieve!

hth,

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Sk Noorul Hassan
Regular Advisor

Re: LIB$SPAWN

My final executable has to run in detached mode, so when I am trying to use LIB$SPAWN, it is not able to execute my dcl script inside. But if I am running 'RUN prog_name' it is executing the required dcl script.

Pls suggest
Jan van den Ende
Honored Contributor

Re: LIB$SPAWN

Sk,

re-read yesterdays answer by Robert Boyd and myself: RUNning SYS$SYSTEM:LOGINOUT with /INPUT= will execute in an environment that knows about DCL.

hth

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Sk Noorul Hassan
Regular Advisor

Re: LIB$SPAWN

Thanks, Now I am able to run the dcl script inside my program as suggested by Jan & Robert.

The next part is :

When my server is directly comming as duty server, it will work. But in my standby server where all the processes are remain in HIB. Once duty server crashed, the standby server processes will come into LEF & CEF state and will become duty server. So what should I do for taking care that part ?
Hein van den Heuvel
Honored Contributor

Re: LIB$SPAWN


Well, we would need to know how your interprocess communication scheme looks like.

One nice, VMS, solution for this problem is for the main server to take out an application defined lock (SYS$ENQ), and holds it. The slave or alternate server then tries to also take out the lock (SYS$ENQW) and waits for it. When the master dies, the slave gets the lock automagically and becomes the master.

A nice variant can be not to worry about who initially becomes the master slave. Who-eveer gets the lock first is the master.


If the master needs help, it coudl release the lock, with a short mesage in the Lock Value Block to tell a slave to come to help.

Instead of waiting and be blocked, the slaves could also set up a blocking AST to be notified when the lock is free.

fwiw,
Hein.
Sk Noorul Hassan
Regular Advisor

Re: LIB$SPAWN

Thanks. I am able to run DCL script in a detached way using $CREPRC & $CREMBX.My DCL script consists of
$ telnet/create_sess 10.192.10.12 2001 1
$ set term tna1:/perm/spedd= .......
$ set prot=(S:rwlp,O:RWLP,G:,W:)/dev TNA1:

Now when I am executing this dcl script through small pascal code consists of $CREPRC & $CREMBX, it is successfully creating the device TNA1: with desired protection(S:rwlp,O:RWLP,G:rwlp,W:). But when I am putting this pascal code inside my main pascal program and executing it, it is unable to execute the "$ set prot=(S:rwlp,O:RWLP,G:,W:)/dev TNA1:" while it is executing the remaining lines successfully.But, It is creating the device TNA1: with only (S:rwlp,O:RWLP,G:,W:)protection for any combination of "rwlp" for S, O,W & G.

Pls suggest, is it a account/process priviledge issue ?
Sk Noorul Hassan
Regular Advisor

Re: LIB$SPAWN

In continuation to my earlier reply,

When I am trying to run my main program in run prog_name/detached/proc=proc_name it is successfully setting the protection but when I am trying to use customised tool to start the process it is unable to set the protection.

Arch_Muthiah
Honored Contributor

Re: LIB$SPAWN

Sk,

I observe your are keep getting very good responses for all your questions from most of our forum senior members; they are spending their valuable timings to go thru your issues and compsing the suggestions.

But I found from your forum Profile:


I have assigned points to 83 of 172 responses to my questions


May be you please can find some time to do some assigning points?

Mind, I do NOT say you necessarily need to give lots of points. It is fully up to _YOU_ to decide how many. If you consider an answer is not deserving any points, you can also assign 0 ( = zero ) points, and then that answer will no longer be counted as unassigned.


Btw: I don't understand this command. Does it works for you?
$ set prot=(S:rwlp,O:RWLP,G:,W:)/dev TNA1:

Also what is the value you assigned for UIC argument of your $CREPRC service. Is it default value (same UIC of parent process) or difft UIC?


Archunan

Regards
Archie