#!/bin/sh and #!/bin/ksh

Hi All,
I have a shell (#!/bin/sh) with below piece of code:

if ! [ $TP_PASS = 1 ]
then
echo Staging table ABC_INT_TAB is not present in the schema >> $OUTPUT
fi

Shell is throwning below error and continue to work even after this error
/d01/app/oracle/frmuatappl/custom_ar/1.0/bin/oasis_cash_recp_conversion_abc_prog.prog: !: not found

Now we changed this shell to ksh as:
#!/bin/ksh

if ! [ $TP_PASS = 1 ]
then
echo Staging table ABC_INT_TAB is not present in the schema >> $OUTPUT
fi

I am not getting this error now.

Help me to find out whats wrong with first shell.
(In first sh shell i think it is never going in if condition.)

Thanks

try

if [ $TP_PASS != 1 ]

"if" expects a program to run. "!" is not a program on your system. You could try writing a program called "!" which ran it's arg list and inverted the exit code.

But how does ksh and sh makes difference.
ksh is working fine with : if ! [ $TP_PASS = 1 ]
sh does not work with this.

Thanks

They are different shells.

Some commands are implemented inside the shell, some are external, "if", "source" "cd" are examples of such statements.

Also, some systems also link /bin/sh to either ksh or even bash rather than just an implementation of "sh"