Page 1 of 1

Problem with using BPX1SPN

PostPosted: Thu Feb 27, 2020 10:14 pm
by chong_zhou
I need to directly execute a USS programme in an MVS programme written in assembler. The MVS programme is executed by a batch job.

I cannot submit another job to execute the USS programme and the executing programme (the MVS programme) must be written in assembler. Rexx or other languages are not options for me.

After spending a lot of time searching the IBM knowledge centre, I figured that the system callable service BPX1SPN (or BPX4SPN) seems to me best bet.

However, I got a problem when doing an experiment:

Since the real USS programme is not ready yet, I wrote a hello world LE C programme which creates a text file in my home directory and writes something in it. I wanted to use the message file to confirm that the USS programme was correctly executed.

The problem (symptom) is that: BPX1SPN returned successful code (RC=0) and also gave me the USS process ID for the execution of the programme. But the message file wasn't created at all. Do you have any experience working with BPX1SPN? Did you have similar problem when using it? Or, any ideas? suggestions? Thanks!

Sorry for the nagging. Just trying to explain it clearly.

Re: Problem with using BPX1SPN

PostPosted: Thu Feb 27, 2020 11:04 pm
by Robert Sample
Since the real USS programme is not ready yet, I wrote a hello world LE C programme which creates a text file in my home directory and writes something in it. I wanted to use the message file to confirm that the USS programme was correctly executed.

The problem (symptom) is that: BPX1SPN returned successful code (RC=0) and also gave me the USS process ID for the execution of the programme. But the message file wasn't created at all. Do you have any experience working with BPX1SPN? Did you have similar problem when using it? Or, any ideas? suggestions? Thanks!
Did you use absolute path reference in BPX1SPN or relative path? Did you use absolute or relative path reference in your LE C program? Does your site use FORKCOPY(COW) OR FORKCOPY(COPY) in your SYS1.PARMLIB? It is not unusual for the user id of a batch job to not be the TSO user id you used, so the message file may not have been created due to permissions or it may have been created in the wrong directory.

Re: Problem with using BPX1SPN

PostPosted: Thu Feb 27, 2020 11:40 pm
by chong_zhou
Hi Robert, I didn't find the FORKCOPY parameter in the SYS1.PARMLIB (I did srchfor).
I'm using absolute path and I also tried my home directory and the /tmp.
In terms of permission, I tried to execute the USS programme using BPXBATCH in a batch job, it can create the message file in that case.
Anyway, thank you for your suggestions.

Re: Problem with using BPX1SPN

PostPosted: Thu Mar 05, 2020 3:29 pm
by chong_zhou
This is the final update for this thread. I finally made it work, and I'd like to brief what I did in case it would help someone in the future.

I am using the USS callable service, BPX1SPN, to invoke a mock shell script in the USS file system. In the script, I run a hello-world LE C program which creates a plain text file and sleeps for 60 seconds as well.

The problem that made me create this post was that, although the BPX1SPN gave me RC=0, RSN=0, and a looks-good process ID, the plain text file wasn't created and the sleep(60) didn't happen at all. In other words, the BPX1SPN told me everything was fine, but the commands in the mock shell script weren't executed at all. That was strange.

After a long time of trying, googling and asking, I made it work almost by chance ---

I added " #!/bin/sh " in the shell script and after that things started to work. The plain text file was created and the 1-minute delay happened.

Although it is not explained in the document why the " #!/bin/sh " is required, and so, neither do I know what actually happened under the table, anyway, I can make the following conclusion:

" #!/bin/sh " is required in the shell script if the script is executed by BPX1SPN.

Re: Problem with using BPX1SPN

PostPosted: Thu Mar 05, 2020 4:11 pm
by enrico-sorichetti
" #!/bin/sh " is required in the shell script if the script is executed by BPX1SPN.


NO...
the shebang line is REQUIRED if You want to execute any script simply typing its name in the <terminal> window
it tells to the session controlling SHELL what executable to invoke to interpret the script

with the shebang line You simply enter
yourscriptname

without it You must know the language of the script and enter the appropriate script processor name
sh/bash/zsh/csh/python/python2/python3/perl/rexx yourscriptname

it would be wise to review Your understanding of the Unix-like systems behaviour when using an explicit or canned shell environment