I am working in HP-UX (B.11.23) to LINUX (Red Hat Enterprise Linux Server release 6.5 - Santiago) migration project. There were several occurrences where HP-UX commands were not working properly in Linux. But, in following situation - I am facing some difficulties to find out an alternate solution.
Following piece of code is just an example from a script, but requesting you to understand the final outcome of the code.
## Assigning a text value in retval (bad path scenario)_ retval="ERROR" if [ $retval -eq 7 ] then echo "I am in " $retval fi exit $retval
Executing this code in LINUX...
LINUX $> ksh --version version sh (AT&T Research) 93u+ 2012-08-01 LINUX $> ksh -x test12.ksh + retval=ERROR + [ ERROR -eq 7 ] + exit ERROR tpl06429dat05::edwprod::/home/edwprod >echo $? 0 # look here return code of above executed script is 0_
Now, have executed same code in HP_UX
UNIX $> uname -a HP-UX ipeip06 B.11.23 U ia64 ******** unlimited-user license UNIX $> strings /bin/ksh | grep Version | tail -2 @(#)Version 11/16/88 UNIX $> ksh -x test12.ksh + retval=ERROR + [ ERROR -eq 7 ] test12.ksh: ERROR: bad number + exit ERROR test12.ksh: ERROR: bad number UNIX $> echo $? 1 # Look here, return code of above executed code is 1
In Linux, "exit" command is not executed at all as I have passes wrong parameter (string), but in HP-UX there is no problem - "exit" command with wrong parameter has been executed and tells us that it's a wrong command (echo $?) in that script. And this return code is very important as based on this return code ($?), we decide whether a script has been executed successfully (0) or not.
I understand, if we tweak the code, then problem can be resolved. But that's bit difficult here as I am dealing with almost 15K or more such scripts which are written in HP_UX. Is there any possibility to change something at OS level (changing packages/parameters).. What kind of system level changes needed?
On a different note, ksh versions are different and behaves differently. So, it's better if you avoid this answer.