IBM SG24-6526-00 manual Qshell scripts, tail -f /OrderManagement/log.stdout.txt

Models: SG24-6526-00

1 184
Download 184 pages 3.35 Kb
Page 162
Image 162

This can be useful for monitoring log files in real time. The session in which you use this command remains in use. When you are finished, use System Request 2 to stop the command as shown here:

tail –f /OrderManagement/log.stdout.txt

This command shows the last few lines of the standard output file of the Order Management application. If more lines are written, they are output. This is mentioned in 5.4.3, “Verbose garbage collection” on page 126.

6.2.4 Qshell scripts

It is possible to save Qshell commands in stream files for later execution. This is similar to script programming in UNIX and to DOS batch files. The concept is similar to CL programs, but the details are different.

This is a complex subject considering that there are some powerful programming techniques available. We only briefly describe a few simple abilities. Familiarity with DOS batch file programming can help, but there are quite a few differences.

Qshell scripts are stored in stream files in the IFS. You can create and edit them using any of the editing techniques described earlier such as a PC editor against a mapped drive or the OS/400 EDTF command. If you create the script with EDTF first, then it may be given an EBCDIC CCSID and you won’t be able to edit it from the PC later.

The names, or even the extensions of the names, of scripts are not restricted as DOS batch files are. There are two common conventions. Names without any extension may be used, for example StartSalesApplication, but some PC editors and tools may have problems with such files. The extension .sh is often used, but this is required when the script is executed, unlike DOS where the .bat extension is not required when executing the file. The file names are not restricted to 10 characters and may be very long. Unlike UNIX, case is not significant. It is common to use all lowercase or all uppercase letters for the initial letter of each word of the name to make it easier to read.

At their simplest, script files are one or more Qshell commands that are executed in sequence. Each command should be typed on its own line. Lines that begin with # may be used for comments. The scripts do not need to be compiled, which is like UNIX and DOS but unlike CL.

You execute scripts from Qshell by typing their name. If an extension, for example, .sh, was used, then you must include this as well. You should either be in the directory containing the script, fully qualify its name, or use the PATH facility. You may also execute the script from an OS/400 command display by using QSH with its optional parameter as shown in an example later in this section.

The name of the script may be followed by one or more values that will be available to the script as parameters. The parameters should be separated by spaces. If the parameter values include spaces, then they should be enclosed in single quotation marks. The parameters may be used inside the script using the special variables $1 for the first parameter, $2 for the second, etc. This is similar to DOS, except that in DOS, the variables are %1, %2, etc.

You can define additional variables within the program. A variable is set simply by choosing a name and writing a line with that name followed by = and then by the desired value as shown in the following example. If the value contains spaces or certain special characters, then it should be in quotation marks.

DIRECTORY=/OrderManagement

150Geac System21 commerce.connect: Implementation on the iSeries Server

Page 162
Image 162
IBM SG24-6526-00 manual Qshell scripts, tail -f /OrderManagement/log.stdout.txt, DIRECTORY=/OrderManagement