1823377 Members
2524 Online
109654 Solutions
New Discussion юеВ

ksh: !: not found

 

ksh: !: not found

Hi,

I'm having a problem with HP-UX ksh(1) :

The man page for ksh clearly says:

A compound expression can be constructed from these primitives by using any of the following, listed in decreasing order of precedence.
[...]
! expression True if expression is false.
[...]

Nonetheless, hpux's ksh doesn't seem to behave correctly on that point.

I've tried 3 tests on ksh on Solaris 7 and 8 and Linux. On all teh system the behaviour was correct and as expected:

TEST 1:

$ type !

Expected result (right for all OS, except HPUX)

! is a reserved shell keyword

On HP-UX, we get:

! not found


TEST 2:

$ if ! true
then
echo TRUE
else
echo FALSE
fi

Expected result (right for all OS, except HPUX):

FALSE

On HP-UX i get:

ksh: !: not found
FALSE

(Although FALSE is written on the output, it's due to the fact that the if condition fails because ! is not known by this ksh)


TEST 3:

$ if ! false
then
echo TRUE
else
echo FALSE
fi

Expected result (right for all OS, except HPUX):

TRUE

On HP-UX i get:

ksh: !: not found
FALSE

(we get FALSE for te same reason as above).


On this HP-UX host, the ksh version is:

adumont@psup01$ uname -a
HP-UX psup01 B.11.11 U 9000/800 624653342 unlimited-user license

adumont@psup01$ what $( which ksh )
/usr/bin/ksh:
defs.c $Date: 2002/11/18 20:42:15 $Revision: r11.11/2 PATCH_11.11 (PHCO_27019)
edit.c $Date: 2002/11/18 20:43:06 $Revision: r11.11/2 PATCH_11.11 (PHCO_27019)
io.c $Date: 2002/11/18 20:47:57 $Revision: r11.11/3 PATCH_11.11 (PHCO_27019)
cmd.c $Date: 2002/11/18 20:41:14 $Revision: r11.11/1 PATCH_11.11 (PHCO_27019)
main.c $Date: 2002/11/18 20:52:03 $Revision: r11.11/4 PATCH_11.11 (PHCO_27019)
xec.c $Date: 2002/11/18 20:52:56 $Revision: r11.11/2 PATCH_11.11 (PHCO_27019)
macro.c $Date: 2002/11/18 20:51:03 $Revision: r11.11/2 PATCH_11.11 (PHCO_27019)
error.c $Date: 2002/11/18 20:44:16 $Revision: r11.11/2 PATCH_11.11 (PHCO_27019)
jobs.c $Date: 2002/11/18 20:49:04 $Revision: r11.11/2 PATCH_11.11 (PHCO_27019)
$Revision: @(#) all CUP11.11_BL2002_1129_1 PATCH_11.11 PHCO_27019
Fri Nov 29 08:52:39 PST 2002 $
$ B.11.11_LR Feb 8 2002 01:58:34 $
Version 11/16/88



Does someone have any explanation about that ? Or is it simply a ksh bug on HPUX ??

5 REPLIES 5
KapilRaj
Honored Contributor

Re: ksh: !: not found

if u cover it with [ ] i.e. [ ! $false ]

kaps
Nothing is impossible
Steve Steel
Honored Contributor

Re: ksh: !: not found

Hi


Posix shell works


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Mark Grant
Honored Contributor

Re: ksh: !: not found

As Steve says, "ksh" on HPUX is not quite the thing to use. Use the posix shell "/usr/bin/sh". This is not the bourne shell as it first seems.
Never preceed any demonstration with anything more predictive than "watch this"

Re: ksh: !: not found

Thanks for your reply.

I know that sh-posix(1) is a better shell. IMHO, i really like it much more than ksh.

The problem is that i'm trying to write a script that will have to run on any platform (a monitor for OVO).

I'm badly surprised that "!" is not recognized by the hpux's ksh. I think it's a bug.

The only problem i find to sh-posix(1) is that i have only been able to use it on hp-ux. (but not all the systems are hp-ux -- unfortunately ;) ). AFAIK, it's not available under Solaris neither Linux.

I've also tried with [ ! expr ], but it doesn't work correctly neither.

Any other suggestion?
Mel Burslan
Honored Contributor

Re: ksh: !: not found

I know it is a duplicate effort but how does having two versions of the script pushed out to all the clients with a OS type check at the beginning sound. Initial script can run only once and according to the OS type test result you can delete the unnecesary one, ksh version for hpux and posix version for all others. I know this is not ideal or a full solution in the literal meaning of the word, but at least it can buy yo some time until you come up with something more permanent. A workaround more than anything else.

my 2 cents
________________________________
UNIX because I majored in cryptology...