Qshell Scripting


You may create a text file of Qshell commands that can be executed as a unit. Such a file is called a script, and is similar in nature to a program written in a language like RPG, CL, or Java, except that scripts are interpreted, not compiled.

The Qshell language is a powerful one, including such features as:

  • Variables

  • Positional parameters

  • Looping structures

  • Decision-making structures

  • Internal functions (similar to subroutines)

It is worth noting that the Qshell language does not have some things. For one, it has no object-oriented features, as are found in Javascript and Perl. Nor is there a branching feature like the GOTO command found in many programming languages. The absence of such features is not a problem.

For performance reasons, it is best to place scripts in the root system of the IFS. That is not to say you can't use other file systems. Qshell can run a script stored in a source physical file member, and there's no reason you shouldn't place a script in a source physical file member if doing so fulfills a purpose. But, as a general rule, the root file system is the place to put scripts.

You can use any editor you like as long as you have the appropriate connection to the i5 system. If you want to edit from a terminal session, you can use CL's Edit File (EDTF) command. The EDTF editor is similar to the Source Entry Utility (SEU) in many ways, but not nearly as powerful. EDTF is good for quick changes or small projects, but for ongoing development that includes Qshell, it is better to use a PC workbench.

Figure 27.4 contains a script that creates backup copies of data files.

image from book
Figure 27.4: You can develop powerful scripts using Qshell.



IBM i5/iSeries Primer(c) Concepts and Techniques for Programmers, Administrators, and Sys[... ]ators
IBM i5/iSeries Primer(c) Concepts and Techniques for Programmers, Administrators, and Sys[... ]ators
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 245

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net