I have a number of Korn scripts I've used successfully for years in AIX (4.3 and 5.x) and Solaris (9 and 10). Recently I've had to start porting them to HP-UX (11i V3) and run into a few unexpected incompatabilities. For one, the "!" operator does not seem to work reliably (as in "if (! command) ..."), nor does the "==" operator.
I've researched this a bit, and from what I've seen it appears that HP's version of ksh is rather old (11/16/88c). Does anyone know of a list of differences between HP's ksh and more modern ones, perhaps with ideas on how to program around them? In a few cases, it's gotten messy enought that I simply gave up and changed the calling shell to bash, which works reasonably well, but there are enough differences there that that's not a one-size-fits-all solution, either.
I have a number of Korn scripts I've used successfully for years in AIX (4.3 and 5.x) and Solaris (9 and 10). Recently I've had to start porting them to HP-UX (11i V3) and run into a few unexpected incompatabilities. For one, the "!" operator does not seem to work reliably (as in "if (! command) ..."), nor does the "==" operator.
You have illustrated the reasons for using only POSIX syntax in scripts.
Quote:
I've researched this a bit, and from what I've seen it appears that HP's version of ksh is rather old (11/16/88c). Does anyone know of a list of differences between HP's ksh and more modern ones, perhaps with ideas on how to program around them? In a few cases, it's gotten messy enought that I simply gave up and changed the calling shell to bash, which works reasonably well, but there are enough differences there that that's not a one-size-fits-all solution, either.
The POSIX shell on HP-UX is /usr/bin/sh .
See "man sh" for an explanation of the various shells.
BTW. The syntax you describe looks more like "csh" than "ksh". An "if" test in "ksh" would have square brackets not round brackets. Also the "==" is valid in "csh".
You have illustrated the reasons for using only POSIX syntax in scripts.
While I agree, I'm not sure I see your point. O'Reilly's "Learning the Korn Shell" makes no mention of POSIX concerns with either of my examples. (In fact, page 143 of the 2nd edition specifically states that the "!" keyword was introduced in POSIX.) I'm certainly no POSIX guru, though, so perhaps I've misunderstood your intent.
In any case, if HP's ksh is as old as it appears, it's probably not POSIX-compliant to start with, and using POSIX syntax may be the cause of the problem, not the solution. So my original question stands - does there exist a list of version incompatabilities between HP's ksh and more modern ones?
Believe it or not, I browse those pages often when I'm developing new scripts, and they recently went offline (again).
Quote:
Originally Posted by methyl
The POSIX shell on HP-UX is /usr/bin/sh
The script I'm currently working on contains the following:
On HP-UX 11i V3, both /bin/ksh and /usr/bin/sh choke with a syntax error (`==' unexpected). The original script runs fine on Solaris and AIX. What about this statement is non-POSIX? If I drop the test to single braces and change the "==" to "-eq" both ksh and sh are happy.
Last edited by DukeNuke2; 06-04-2009 at 03:41 PM..
The script I'm currently working on contains the following:
On HP-UX 11i V3, both /bin/ksh and /usr/bin/sh choke with a syntax error (`==' unexpected). The original script runs fine on Solaris and AIX. What about this statement is non-POSIX? If I drop the test to single braces and change the "==" to "-eq" both ksh and sh are happy.
You're lucky, then. The -eq operator is for comparing integers, not strings.
You're lucky, then. The -eq operator is for comparing integers, not strings.
The correct test (in any Bourne-type shell) is:
Correction noted. My point was that the "==" works on the other platforms I use and had no reason to think it would not work here. Is the "==" operator non-POSIX?
I have the following file:
one two three four
man women
yes no place togo
bad sleep
I need to move all lines that have only two words(columns) in a separate file and the rest in a separate file...
I used :
for $linecont in $(cat $filename); do
echo $linecont > temp
line1='cat... (7 Replies)
Hi,
I have command like this with ooutput :
unix>tnsping abc
TNS Ping Utility for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Production on 17-AUG-2011 17:06:11
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
/opt/oracle/network/admin/sqlnet.ora
... (19 Replies)
I'm getting different behaviour when executing below script in debug option.
$ cat ss.ksh
ff=$(pwd)
echo " ff : $ff"
$ ksh ss.ksh
ff : /tmp
$ ksh -x ss.ksh
+ + pwd
ff=
+ echo ff :
ff :
I was getting this behaviour in my actuall script i'm able to reproduce this in simple script... (4 Replies)
Hi ,
What is the diffence between executing the script like
./myscript.ksh
. ./myscript.ksh
I have found 2 difference but could not find the reason
1. If i export a variable in myscript.ksh and execute it like . ./myscript.ksh the i can access the other scripts that are present in... (5 Replies)
In csh I use
opt=` echo $arg | awk 'BEGIN {FS="="} {print $1}' `
I am wondering what I should use when using ksh
opt=$(print -R $arg | awk 'BEGIN {FS="="} {print $1}')
or
opt=` print -R $arg | awk 'BEGIN {FS="="} {print $1}' ` (31 Replies)
Hi
I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email.
For example
-------
Script ABC
-------
a.ksh
b.ksh
c.ksh
I need to call all three scripts execute them and... (2 Replies)
Ih all,
i have multiples ksh scripts for crontab's unix jobs
they all have same variables declarations and some similar functions
i would have a only single script file to declare my variables, like:
var1= "aaa"
var2= "bbb"
var3= "ccc"
...
function ab { ...}
function bc { ... }... (2 Replies)
I normally trace a script with the ksh -x <script name> and redirect strderr to file. But if you have a script like the examble below......
vi hairy
bear=`grep bear animals`
if
then
ksh more_animals
fi
If I ksh -x hairy it won't trace "more_animals" unless I put a -x in it. Is... (1 Reply)
Hi,
I'm new to unix scripting.How can i call a script from another script.
I have a.ksh and b.ksh .I have to call b.ksh from a.ksh after it is successfully exceuted.
I tried using
#!/bin/ksh -x in a.ksh and at the end i have used /path/b.ksh
My problem is it is executing only a.ksh.it... (6 Replies)
Hi there,
I've coded a script to create a menu system on an AIX machine.
When user selects an item of the menu I perform a program using " nohup somepgm &"
The reason I do that is because usually the scripts behind the menu items are very time-consuming and users logout and log back in... (2 Replies)