Reputation: 11
I am new to shell script on iSeries, but i have created one sample script:
#!/bin/ksh
cd /QIBM/Userdata/employeedetails/
pwd
ls -ltr
I placed it under /QIBM/testscript.ksh
and tried to run the script on the main menu using STRQSH CMD('/QIBM/testscript.ksh')
I got this error, can someone please let me know what did do wrong here?
qsh: 001-0014 Command /QIBM/testscript.ksh not found.
Press ENTER to end terminal session.
I am wondering, is it possible to create shell script on the iSeries (AS/400)?
Upvotes: 1
Views: 3883
Reputation: 676
Did you make the script executable? Unless you have *ALLOBJ authority, you must mark the script executable by executing either
chmod 755 /QIBM/testscript.ksh
from a shell or
CHGAUT OBJ('/QIBM/testscript.ksh') USER(USRNAME) DTAAUT(*RWX)
from CL
It also looks like you maybe forgot the # in the first line, unless it's just a Stack Overflow formatting mistake. Your first line should be:
#!/QOpenSys/usr/bin/ksh
as ksh is not found in /bin on IBM i.
Upvotes: 1
Reputation: 41168
It is certainly possible to create a shell script.
The default shell is Qshell which can be referenced as /bin/qsh
or /bin/sh
.
echo '#!/bin/sh
pwd
ls -ltr' > $HOME/testscript.sh
To run it:
STRQSH CMD('$HOME/testscript.sh')
Korn shell is available with IBM PASE for i at /qopensys/usr/bin/sh
or /qopensys/usr/bin/ksh
.
Also I would advise against putting things in the /QIBM
directory. I suggest $HOME
or /opt
. See the Filesystem Hierarchy Standard for more information.
Upvotes: 1