I have since discovered that QSHELL has become much more. It is now the equivalent of any other UNIX shell.
However, now I'm asked, 'Why should we adopt UNIX, when we have such a good operating system as OS/400 and the advance scripting language CLLE?' The answer is that QSHELL helps CL rather than competes with it. Here are few ways that you can use QSHELL in your day-to-day life of programming. Usage for database operation CL has a major restriction of using Data Manipulation Language (DML) such as Update, insert or selected delete with the DB2/400 database.
Here is an example of the message I get when trying to delete these folders: You need permission to perform this action. You require permission from SYSTEM to make changes to this file. Deleting an integrated file system user-defined file system. Removing a folder........... Or the WRKLNK command to copy, remove, or rename the /tmp directory or objects in the directory. Series of real-life applications.
To achieve this, we use roundabout ways such as RUNSQLSTM, writing new RPG program, etc. Qshell makes life easier by using the following command: Syntax: QSH CMD('db2 ') Example: QSH CMD('db2 'UPDATE MYLIB.MYFILE SET MYFLD = 'P'' ') QSH CMD('db2 'INSERT INTO MYLIB.MYTABLE VALUES('jagannath', 104.20)') Things to note: • The query naming convention is SQL not SYS. The table/file is qualified with Library.Table not Library/Table.
• The QSH command cannot access the objects, which are created in QTEMP using command line or CL programs. That's because shell commands are executed in a separate job other than the parent jobs. These jobs are triggered automatically when QSH command is executed. If there is a file as QTEMP/MYFILE and I want to update it using this QSH command QSH CMD('db2 'UPDATE QTEMP.MYFILE SET MYFLD = 'P'' ') It will generate an error message such as this one: NATIVE ERROR CODE: -204 MYFILE in QTEMP type *FILE not found. Press ENTER to end terminal session. Usage for IFS operation It is always a headache to handle IFS files using RPG programs.

We have to write separate RPG programs using C APIs to handle this functionality. But QShell commands ease this process. Syntax: To replace the contents of the IFS and write the fresh text QSH CMD('print It is working > /home/mydir/myfile.txt') To append to the contents of the IFS file in next line QSH CMD('print It is working >> /home/mydir/myfile.txt') To use other features of print, go through the QSHELL manual of IBM. I found this functionality helped me while creating CSV files out of database files using CPYTOIMPF.
With this command we create the comma separated files out of the database file. To add the report headings, field descriptions, etc., the print command helps a lot.
Example: QSH CMD('print ',,,Report for Health Care,' > /home/mydir/myexport.csv') QSH CMD('print 'Patient,Date of Adm,Doctor Attended, Remarks' >> /home/mydir/myexport.csv') CPYTOIMPF FROMFILE(MYLIB/HLTHCAR) TOSTMF('/home/jlenka/myexport.csv') MBROPT(*ADD) RCDDLM(*CRLF) Redirecting The output of the QSHELL commands is normally displayed in the standard output. (In UNIX terms, standard output (screen) is also called as a kind of file.) However, we can redirect this output to an IFS file. Since regular programmers are more acquainted with DB2/400 files, let's see how we can redirect the output to the DB2/400 files.