Fixed ksh compatiblity

Tested and fixed script for ksh on AIX 7.1, should work on every linux
that has ksh / pdksh installed