If over the last few months or years, you thought of acquiring UNIX - or Linux - skills but never had the time, the opportunity or a platform to use it, this article may for you. The iSeries operating system now offers a built-in UNIX environment. This new environment is named QSHELL.
Why QSHELL? The first question one may want to ask is why did IBM come up with this 'QSHELL' environment in the first place? The answer is that to be fully Java compliant, IBM needed to supply a JDK (Java Development Kit) on its iSeries eServer that could run standard Java commands such as Java, Javac or Javadoc, the same way other (UNIX) systems could.
There is only one snag, OS/400 does not happen to be 'a flavor of' UNIX. The OS/400 IBM team resolved this hurdle by supplying a new 'UNIX style shell' on the iSeries and appropriately named it 'QSHELL'.
The purpose of this article is to give a quick overview of how QSHELL works, and provide a strong tutorial base and an example of shell script which can be run on a UNIX platform as well as your own iSeries using QSHELL.
Jumping In
To start QSHELL, simply type the OS/400 command 'STRQSH' on the command line. Once there, what you will see is not very different from an ordinary green-screen QCMD session, with a different set of commands.
At first glance
The first thing you will see after entering the QSHELL environment is a screen saying
'QSH Command Entry' , and a '$' character
To know what you can do with QSHELL, there is no 'HELP' command, and the F4 key is plainly ineffective. If you wish to know what tools you have, you need to get yourself to the /usr/bin directory. To do this, you have to type the command 'change directory to /usr/bin' – the actual command below is
cd /usr/bin
From there, you can confirm where you are by typing a 'Print Working Directory' – the actual command below ispwd
Once there, you can see the contents of the /usr/bin directory by using the command ls
or as I prefer to use it,
ls –ltra
in this case, the command modifiers
'a' means 'all', do not hide the directory entries starting with '.'
'l' means 'long', show all the details about each entry
't' means sort by modification time
'r' means reverse order for the sort. Effectively, the latest entries will be the last ones in the listing, which is practical for reading.
Note that the order of these command modifiers is not important. ls –artl is interpreted same as ls –ltra
You can also type, from the original directory the command
ls –ltra /usr/bin
This sounds basic, but ls and pwd are some of the most useful commands. You will use them often in this environment.
The directory structure, in UNIX, starts with '/'. The '/' directory is also known as the 'root' directory. Each directory branch grows from the previous, just like in DOS or in Windows. The directory structure in this environment can have n levels.
The equivalent of the '/' root directory in UNIX in the traditional iSeries environment is the QSYS library. However, on the iSeries, we have a single level of libraries: all libraries are in QSYS, no library can be in a library if it is not QSYS.
In UNIX, a directory can be in a non-root directory.
One other important feature of the UNIX file system: unlike the iSeries or NT, it is case-sensitive. This means that a file named caseSENSTIVE is not the same as a file named CASESensitive. They will be listed and recognized by the operating system as two distinct files. This is critical if you write shell scripts
mkdir /mysandbox
This action of creating a QSHELL directory is similar to creating your own library. Within that directory, you can store your own shell scripts without cluttering the root area, which you want to keep clean if possible
There are many UNIX commands to play with, and for now, I have given focus on the method of using QSHELL rather than explaining too many commands... Watch out for my other articles soon regarding this , till then folks keep trying using QSHELL in ur System .....