IBM Support

Setting the PATH Environment Variable to Include the Current Working Directory in Qshell

Troubleshooting


Problem

This document will cover what the PATH environment variable and the Current Working Directory concepts mean, the different ways the current working directory can be included in the PATH environment variable, and its effect in the Qshell environment.

Resolving The Problem

Current Working Directory

Within the Qshell Interpreter environment, commands that you type are executed in terms of your current working directory. You could say the current working directory is the directory in which you are currently located or reside in. Whenever you start a new Qshell Interpreter session, your current working directory is set to your home directory by default, for example, /home/user.

PATH Environment Variable

The PATH environment variable is a colon delimited list of directories that tells Qshell where to find commands. The default value is PATH=/usr/bin:
When a command is not fully qualified at execution time, a list of directories to search for the command is retrieved from the PATH variable.

If the PATH variable is set to /usr/bin:/QOpenSys/usr/bin:

Qshell first looks for the command in the /usr/bin directory, then in the QOpenSys/usr/bin directory, and finally in the current working directory. When the PATH variable begins or ends with a colon or contains two adjacent colons, qshell searches in the current working directory. A period can also be used to signify the current working directory. The period can be located anywhere in the PATH variable as shown in the examples below.

Examples when the current working directory would be searched:

::/usr/bin:/QOpenSys/usr/bin - double colon at the beginning
/usr/bin::/QOpenSys/usr/bin - double colon in the middle
/usr/bin:/QOpenSys/usr/bin:: - double colon at the end
:/usr/bin:/QOpenSys/usr/bin - colon is located at the beginning
/usr/bin:/QOpenSys/usr/bin: - colon is located at the end
.:/usr/bin:/QOpenSys/usr/bin - period is used at the beginning
/usr/bin:.:/QOpenSys/usr/bin - period is used in the middle
/usr/bin:/QOpenSys/usr/bin:. - period is used at the end

Examples when the current working directory would not be searched:

/usr/bin:/QOpenSys/usr/bin - no colon at the beginning or end, no period, and no double colon

Effects in Qshell

Let's say the command you want to execute resides in the current working directory. In this case, your current working directory is "/home/user". The PATH variable is currently set to "/usr/bin:/QOpenSys/usr/bin". Finally, the command you are executing is "qshell_script.sh".

At the Qshell Interpreter command line, enter qshell_script.sh and press Enter. Because the currently working directory is not included in the PATH variable, the following message is returned to standard output:

qsh: 001-0019 Error found searching for command <command>. No such path or directory.

In our case, the exact message would be as follows:

qsh: 001-0019 Error found searching for command qshell_script.sh. No such path or directory.

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"}]

Historical Number

489394362

Document Information

Modified date:
11 November 2019

UID

nas8N1013630