1

I tried to execute a shell script on AIX and it failed because some declaration/instructions (like readarray, array declaration, date command with specific args etc) from shell is not recognized in ksh

I would like to execute this linux script on AIX without rewrite the entire script in ksh.

I tried to run the script using different shebang like #!/usr/bin/env bash or #!/bin/sh but AIX seems still running it through ksh.

Would someone have a solution to run linux shell on AIX ?

« AIX Toolbox for Linux Applications » seems provide to execute linux shell on AIX.

Could someone confirm me this information ?

How can I check if AIX Toolbox is already install on the AIX server ? (i don’t have the administration right on this server)

How to execute AIX Toolbox to run shell script ?

Thanks in advance for your help

Chandrika Joshi
  • 1,211
  • 11
  • 24
Romain
  • 13
  • 5
  • You mean, you wish to run a bash-script ("Linux-scripts" nowadays use the minimalistic `dash` to achieve compatibility). That's possible, if you install bash. You might already have it installed in /opt/freeware/bin -- check it. – Lorinczy Zsigmond Apr 15 '19 at 10:37
  • Mind you date(1) isn't part of the shell; AIX!date _is_ inferior to GNU!date. – Lorinczy Zsigmond Apr 15 '19 at 10:41
  • If you want to write cross platform shell scripts, your best bet is to stick only to posix shell features and only use programs (and options) described by posix. – Shawn Apr 15 '19 at 19:00

2 Answers2

0

As you can see from the link you can install AIX Toolbox for Linux Applications and you will have bash. Also you can download only this package and install it.

After install you can exec bash as any other program in your OS.

But in generally you can reach a lot of challenges when try to run linux script on AIX or HP-UX.

Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31
0

You can use bash! Need to install yum from here. Once yum is installed it will auto-install bash package. Put in a temporary empty folder, untar it and install all RPMs: rpm -Uvh *.rpm.

Edit /etc/security/login.cfg anb and "/usr/bin/bash" in the end:

shells = /bin/sh,/bin/bsh,/bin/csh,/bin/ksh,/bin/tsh,/bin/ksh93,/usr/bin
/sh,/usr/bin/bsh,/usr/bin/csh,/usr/bin/ksh,/usr/bin/tsh,/usr/bin/ksh93,/usr/bin/
rksh,/usr/bin/rksh93,/usr/sbin/uucp/uucico,/usr/sbin/sliplogin,/usr/sbin/snappd,
/usr/bin/bash

Add path /usr/bin/bash to /etc/shells:

# echo “/usr/bin/bash” >> /etc/shells

Change shell to se bash:

# chuser shell=/usr/bin/bash root

Create a new .bash_profile inside root's home with:

# .bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PS1="[\u@\h \w]\$ "
export PS1

Login with root and you see something like this:

[root@aixserver ~]#
Mr. Toth
  • 11
  • 1