Page 1 of 1

Using QShell (QSH) cmd in a CL program

Posted: Mon Sep 21, 2020 4:02 pm
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.

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

Posted: Mon Sep 21, 2020 5:24 pm
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.

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

Posted: Tue Sep 22, 2020 5:17 pm
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.