You can issue an operating system command to set up an environment in which a request must run. For example, a program may change directories, rename files, unzip files, copy files, or perform other operations before executing a request. After the environment is customized, the program can begin the report and graph requests.
Specifies the operating system.
-DOS or DOS specifies the DOS operating system.
-MVS or MVS specifies the MVS operating system.
-TSO or TSO specifies the TSO operating system.
-UNIX or UNIX specifies the UNIX operating system.
-WINNT or WINNT specifies the Windows operating system.
-VMS or VMS specifies the OpenVMS operating system.
-AS/400 or AS/400 specifies the IBM i operating system, which is also known as AS400 or OS400.
-SYSTEM or ! specifies any operating system.
Is an operating system command.
-UNIX pwd -WINNT chdir -VMS SHOW DEFAULT -AS/400 pwd
The change directory command, which is the cd command on all platforms except OpenVMS (where it is the SET DEFAULT command), may not appear to operate as expected if a second request issues a -UNIX pwd command. An example is when -UNIX cd /tmp seems to be ignored when issued. Operating system commands operate as separate processes, so when the process exits, environmental properties such as variables no longer exist and any change of directory is undone. This behavior is consistent with the non-persistent behavior of server environments that protect one execution from another.
Due to this behavior, a change directory command is typically used as part of a request to execute multiple operating system commands on a single line. The cd command is issued first, then the desired command is issued, so the commands execute as a group. Applications ported from releases prior to Version 7 Release 1.5 or ported from FOCUS may have been coded previously based on persistent behavior and must now be coded to combine the change directory and one or more operating system commands onto a single line.
Most operating systems allow more than one command on a single line by using special separators or surrounding syntax. Each method varies depending on the operating system. The following are examples using the required syntax for executing (stacking) multiple operating system commands on a single line:
! cmd /c "cd \tmp && chdir && if exist mydata.txt echo got it" ! cmd /c "cd \tmp & chdir & if exist mydata.txt echo got it " ! cd \tmp & chdir & if exist mydata.txt echo got it ! dir mydata & if exist mydata.txt echo got it
! cd /tmp ; pwd ; if [ -f mydata.txt ] ; then echo got it ; fi ! ls mydata.txt ; if [ -f mydata.txt ] ; then echo got it ; fi
! PIPE DIR /SIZE/DATE mydata.txt | SEARCH SYS$INPUT MYDATA ! PIPE DELETE mydata.txt;* /Noconfirm > NL: 2> NL:
For IBM i:
! cd /tmp ; pwd ; if [ -f mydata.txt ] ; then echo got it ; fi ! system "DSPLIB QGPL" ; if [ -f mydata.txt ] ; then echo got it ; fi ! ls mydata.txt ; if [ -f mydata.txt ] ; then echo got it ; fi
Note: Native IBM i commands can be stacked with QShell commands if the native portion uses the QShell system command with the native command portion enclosed in double quotes.
Some operating system commands perform a function and do not display additional output. For example, the following commands do not display any output when the command is executed:
-UNIX cp a.fex b.fex -DOS copy a.fex b.fex
Other commands return output when the command is executed. For example, the following commands display a list of files in the current directory that ends in fex:
-UNIX ls -l grep fex -DOS dir *.fex
WebFOCUS does not display operating system command results in the browser. To review the results of an operating system command, you must redirect the output to another file.
For example, the following commands redirect the command output to a file named OUTPUT (which you can review later in an editor):
-UNIX ls -l grep fex > /tmp/output -DOS dir *.fex > c:\tmp\output