The problem is that the .sh is in my home folder /home/jerry and the
CALL PGM(QP2SHELL) PARM('tstcat.sh')
does not find it in my home folder.
Please make sure you understand the difference between "home directory",
and "current directory". They are two different things.
The syntax you are using (i.e. 'tstcat.sh' with no directory qualifier)
means "open this file in my current directory". It's a relative path
name. RElative path names always start with the current directory, and
go forward from there. Since you don't list any other directories in
the path, tstcat.sh must be in the current directory.
There are times when your home directory is your current directory. But
that's not always the case.
By default, when your job starts:
a) The system looks up the "home directory" from your user profile.
b) If the home directory exists, it's set as your current directory. If
not, the / directory (the "root" directory) is set as your current
directory.
However -- CURDIR is just like *CURLIB. Just because the job starts
with a particular CURDIR doesn't mean that it'll be set to that
directory for the entire time your job is running. Just as a user can
change his/her *CURLIB with the CHGLIBL or CHGCURLIB commands, so also
can a user change his CURDIR with the CHGCURDIR, CHDIR or CD commands.
Also, programs can change these things (either CURLIB or CURDIR) if they
want to. So it's not safe to assume that your curdir will always be
your home dir.
You might try running DSPCURDIR (assuming this is an interactive job)
immediately before running your PASE script to see what your CURDIR is
in both environments.
At any rate, IMHO, this is all moot, since you shouldn't be doing it
this way to begin with! You should not hard-code the location of the
script for much the same reason you shouldn't hard code a library on the
CALL command. Just as you want to use *LIBL when you use the CALL
command, you should be using PATH when you invoke a QShell/PASE script.
The way you've coded things, you've hard-coded (without understanding,
I'm sure) that the script MUST be in your curdir. Instead, use CALL
QP2SHELL PARM('/qopensys/bin/sh' '-c' 'tstcat.sh') so that it will
invoke the script in your PATH.
Then the user can set the PATH appropriately, just like they would do
with *LIBL.
That implies that /home/jerry is NOT my current folder. I am not
setting a home folder on a machine where it works so I am trying to
understand why it is working on one and not the other.
Because the curdir isn't the same. Maybe /home/jerry doesn't exist. Or
maybe your home dir isn't /home/jerry (you can set a home directory to
anything you like, it doesn't HAVE to be /home/USRPRF... that's just the
default) or because the curdir isn't the same as the home directory
because something else changed the curdir... lots of possibilities,
but for some reason, the tstcat.sh file isn't in your current directory.
Make sense?
As an Amazon Associate we earn from qualifying purchases.