Using QShell (QSH) cmd in a CL program

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
mperez
New User
Posts: 9
Joined: Tue Sep 10, 2019 10:24 am
First Name: Michael
Last Name: Perez
Company Name: Manhattan Life Insurance
Contact:

Using QShell (QSH) cmd in a CL program

Post by mperez »

From Profound, I am calling a CLP that runs a change directory command in QSH and is failing with exit status 127 (command not found) though it says it ended normally. If I call the CLP from the iSeries command line, it executes the QSH "cd" command without errors. Any suggestions on next steps?

Snippet of the code:
CHGVAR VAR(&SCRIPT) VALUE('CD +
/MY/IFSFLDR/UTILITY')

ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(NONE) +
LEVEL(*JOB) REPLACE(*YES)

QSH CMD(&SCRIPT)

***********************
JOBLOG:
6000 - ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(NONE) LEVEL(*JOB)
REPLACE(*YES)
Environment variable added.
6500 - QSH CMD('CD /MY/IFSFLDR/UTILITY')
Command ended normally with exit status 127.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Using QShell (QSH) cmd in a CL program

Post by Scott Klement »

Hi there,

I suspect its because you have it in uppercase 'CD' instead of 'cd'. Qshell is meant to work like Unix, and the Unix environment is case-sensitive.

That said, I'm not sure why you'd want to do this? Since the QSH command ends immediately after running the cd command, there's nothing that's done in the new current working directory... it switches directories and then just ends without doing anything.

I wonder if you meant to use the CHDIR CL command instead of Qshell? That way, the job's current directory will remain set to wherever you switched to.
mperez
New User
Posts: 9
Joined: Tue Sep 10, 2019 10:24 am
First Name: Michael
Last Name: Perez
Company Name: Manhattan Life Insurance
Contact:

Re: Using QShell (QSH) cmd in a CL program

Post by mperez »

Yes, converting it to lower case 'cd' worked. The other part of the QSH cmd ran a script (cd /My/IFSFldr/Utility && RunScript.sh). The full command kept returning with a "command not found" exception so I decided to test each one separately. But I overlooked the uppercase 'CD' in my test pgm..Thanks for spotting that!

I did change the CL to use the CHDIR cmd instead of including it in the QSH cmd, that's working..thank you.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 0 guests