Troubleshooting
Problem
This document will discuss some considerations that need to be made before creating a shell script in PASE. It also provides links to some reference material within the AIX Information Center.
Resolving The Problem
PASE shell script considerations
| 1. | All UNIX scripts require that only a *LF EOL indicator is used within the script. Syntax errors will arise when the default *CFLF EOL indicator is used. Some of the errors include the following: PASEscript.sh[3]: ^M: not found PASEscript.sh[4]:: 0403-057 Syntax error at line 4 /QOpenSys/usr/bin/-sh: <PASEscript.sh>: not found. If you are creating a brand new script on the IBM i, you can set up the Stream File EOL option within the Edit File (EDTF) utility. Here is how you would change this property: a. Use the EDTF command to create the script file EDTF STMF('/home/script.sh') b. Press F15 (Shift + F3) to access the Services menu. c. From here, you can change the Stream file EOL option. Note: You would want to change this property before you begin to edit the file. d. Type *LF next to Stream file EOL option. e. Type 5 next to Selection at the top of the screen, and press Enter. f. There should be no message displayed after doing this. g. You are now free to edit your file. The file will now only contain *LF EOL indicators. If the file already exists, you can run the following UNIX command to trim the *CR EOL indicators from the file: tr -d '\015' < my-windows-pc-editor-messed-up-script.tmp > mygoodscript.sh |
| 2. | Specify which shell you want to use at the beginning of the script. When creating a shell script, you should indicate which shell interpreter you would like to use to execute the script at the very beginning of the file. This is done by utilizing the shebang (in other words, hashbang, poundbang) (#!) syntax. In PASE, there are several different shells that can be utilized: bsh - Bourne Shell #! /QOpenSys/usr/bin/bsh csh - C Shell #! /QOpenSys/usr/bin/csh sh/ksh - Korn Shell #! /QOpenSys/usr/bin/sh #! /QOpenSys/usr/bin/ksh psh - POSIX Shell (aka Korn Shell) #! /QOpenSys/usr/bin/psh The Korn shell is the standard operating system login shell and is backward-compatible with the Bourne Shell. Example of setting a script to use the C Shell: <--Start of Script #! /QOpenSys/usr/bin/csh print Hello World <--End of Script |
AIX Reference Material
Operating System Shells:http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.baseadmn/doc/baseadmndita/shells.htm
Korn Shell:
http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.baseadmn/doc/baseadmndita/korn_shell.htm
Bourne Shell:
http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.baseadmn/doc/baseadmndita/bourne_shell.htm
C Shell:
http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.baseadmn/doc/baseadmndita/c_shell.htm
[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"}]
Historical Number
595516182
Was this topic helpful?
Document Information
Modified date:
18 December 2019
UID
nas8N1011601