Error “platform=${platform/\)/%29}: bad substitution” when installing an Enterprise Manager Agent with AgentPull method on AIX

Today, I have been asked to deploy several Oracle Enterprise Manager agents on AIX 7.1 servers.
For this type of request, I have a preference for the “AgentPull” method when I don’t have a suitable Gold Image available.
Unfortunately, it seems that the “AgentPull” script does not work properly on AIX machines because when executing it, I got the following error: “platform=${platform/)/%29}: bad substitution“.

What’s going on?

When you install an Enterprise Manager agent with the AgentPull method, you must pass the name of the platform as a parameter (retrieved via “showPlatforms”). For AIX server, it must be “IBM AIX on POWER Systems (64-bit)“:

oracle@myaixserver> ./AgentPull.sh -showPlatforms

Platforms       Version
IBM AIX on POWER Systems (64-bit)       13.4.0.0.0
Linux x86-64    13.4.0.0.0

The AgenPull script formats the name of the platform passed via the “PLATFORM” parameter in order to build a URL that will download the correct version of the agent from the OMS server. In order to ensure that the URL generated by the script is valid, the spaces as well as the characters “(” and “)” are converted into HEX.
That’s when the error appears:

oracle@myaixserver> ./AgentPull.sh AGENT_BASE_DIR=/u01/app/oracle/agent LOGIN_USER=SYSMAN LOGIN_PASSWORD="DUMMY" PLATFORM="IBM AIX on POWER Systems (64-bit)" VERSION=13.4.0.0.0 AGENT_REGISTRATION_PASSWORD=DUMMY AGENT_PORT=3872 ORACLE_HOSTNAME=myaixserver

./AgentPull.sh[349]: platform=${platform/\)/%29}: bad substitution

To convert spaces into their HEX equivalent (%20), the script uses “sed”:

platform=`echo $platform | sed -e "s/ /%20/g"`

This does not pose any problem.
On the other hand, to convert the characters “(” and “)” in their HEX equivalent (%29 and %28), the script uses shell Parameters Expansion:

platform=${platform/\)/%29}
platform=${platform/\(/%28}

This is where the error appears! AIX (or at least version 7.1 and lower) does not support this syntax.

How to fix it

You have several ways to get around this error.
Note: the problematic syntax is used 4 times in the script (2 times for the character “)” and 2 times for “(“). Remember to take them all into account.

You can replace the lines containing the parameters expansion with their “sed” equivalent:

platform=`echo $platform | sed -e "s/)/%29/g"`
platform=`echo $platform | sed -e "s/(/%28/g"`

Or you can delete them completely. This solution is, in my opinion, more easily “scriptable” so more convenient when you have several deployments to do.
If you choose this solution, you will have to adapt the way you pass the “PLATFORM” parameter so that the special characters are already in HEX format. For AIX in my case:

oracle@myaixserver> ./AgentPull.sh AGENT_BASE_DIR=/u01/app/oracle/agent LOGIN_USER=SYSMAN LOGIN_PASSWORD="DUMMY" PLATFORM="IBM AIX on POWER Systems %2864-bit%29" VERSION=13.4.0.0.0 AGENT_REGISTRATION_PASSWORD=DUMMY AGENT_PORT=3872 ORACLE_HOSTNAME=myaixserver

Then, all you have to do is have a coffee and wait for the installation to be completed 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *