If your kshell scripts which you migrated from RHEL4 or earlier are behaving strange, for example a small script:
[root@localhost ~]# cat /tmp/test.ksh
#!/bin/ksh
#demonstration
echo “\n”
it’s going to give a new line, right? But no, with the default kshell installed it’s not the same, as redhat 5+ is not using pdksh(public domain korn shell). When we execute the above small piece of kshell code:
[root@localhost ~]# ksh /tmp/test.ksh
\n
[root@localhost ~]#
Which is not a new line output (as expected).
To make it working, do yum install pdksh ( in case your server is registered with the redhat) else you can download pdksh rpm from centos site and do rpm -ivh pdksh-*.rpm
Now next step would be, either remove ksh rpm or better use alternatives command (you need to be root to use it) . Second one option is more useful, so here we go:
[root@localhost ~]# alternatives –config ksh
There are 2 programs which provide ‘ksh’.
Selection Command
———————————————–
*+ 1 /bin/ksh93
2 /bin/pdksh
Enter to keep the current selection[+], or type selection number:2
Select option 2 (showing path to pdksh)
Now test your ksh script.
[root@localhost ~]# ksh /tmp/test.ksh
[root@localhost ~]#
It worked, echo “\n” is working as expected !!
That’s it…
Anuj