- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Linux ksh (pdksh-5.2.14-21) versus HPUX 11.0 k...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2004 10:27 PM
тАО05-27-2004 10:27 PM
A simple example:
On our trusty HPUX server using the ksh, assuming you are in /dev:
if [ -f tty* ]
then
echo file found
fi
results in "file found"
on RHEL 3.0 the result is:
ksh: [: tty0: unexpected operator/operand
because the wildcard expands to tty and tty0 etc...
The files the script needs to test for have a date and time extention. (like file.20040528) And there can be one or more than one. Our ksh script on HPUX had no problems with this. The same script on RHEL 3.0 chokes on the if exists if there is more than one file. Ofcourse the script in question can be changed, (any elegant solutions anyone?)
but I'm worried that I'll run into other incompatibilities in other scripts and I'll have my hands full if I have to test every single script on the box. Any tips?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2004 11:30 PM
тАО05-27-2004 11:30 PM
Re: Linux ksh (pdksh-5.2.14-21) versus HPUX 11.0 ksh
However, I just tried your code on hpux11.0 and 11i and in both cases, although there was no error, it didn't find the file either.
To be honest, I would really recommend you move away from the korn shell and use either "sh" which is the posix shell on HPUX or bash on Red Hat. You may need to bite the bullet and make a few script adjustments.
Would this do
ls *.20040528 > /dev/null && echo "File found"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2004 12:04 AM
тАО05-28-2004 12:04 AM
Re: Linux ksh (pdksh-5.2.14-21) versus HPUX 11.0 ksh
thanks for your reply. my example was a bit stupid, the files in /dev aren't regular files. so it should be like this:
ut23 $if [ -f /usr/bin/lp* ]
> then
> echo file exists
> fi
file exists
actually the script is more like
if [ -f /somewhere/file.* ]
then
dosomething
else
mail somebody that there aren't any files
fi
still annoying that this works on my hpux box w/ the ksh but not on my shiny new linux box with the same shell.
noticed that bash doesn't allow the wildchar there either. so it's not a ksh issue per se and maybe indeed a HPUX ksh bug. Any reactions from the HPUX ksh camp? (if there is such a thing :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2004 12:30 AM
тАО05-28-2004 12:30 AM
SolutionI would say it's a bug in HP-UX ksh. Sorry.
'if [ -f .... ]' stands for executing the test command. Test -f expects 1 argument...
I believe test is a shell built-in.
/usr/bin/test also rejects multiple filenames.
Another nice difference can be found here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=478229
Also expect changes in filenames and locations...
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2004 01:32 AM
тАО05-28-2004 01:32 AM
Re: Linux ksh (pdksh-5.2.14-21) versus HPUX 11.0 ksh
The korn shell provided with HPUX is not really a supported product. The korn shell provided with linux isn't that great either.
The default shell on hpux is /bin/sh and although this looks like it might be the Bourne shell, it isn't. It is the posix shell which is a superset of ksh. It has all the features of the korn shell (without the bugs) plus more.
On linux the default is "bash". It is also a superset of the korn shell and although there are one or two places where I think the bash implementation is not correct, they are small and definately debatable points.
I would really urge you to consider testing your scripts using "bash".
The one liner in my previouls post will do what you wanted by the way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2004 01:37 AM
тАО05-28-2004 01:37 AM
Re: Linux ksh (pdksh-5.2.14-21) versus HPUX 11.0 ksh
The only modification I've had to do is with the echo command.
The korn shell on Linux has been judged by many peers in this forum as "not ready for prime time" and "introducing more problems than it solves."
There are those who like it though. Caveat Emptor.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2004 02:13 AM
тАО05-28-2004 02:13 AM
Re: Linux ksh (pdksh-5.2.14-21) versus HPUX 11.0 ksh
We have a RHEL 2.1 system where our vendor specified that they had to use ksh for their shell scripts. We objected, as the only ksh we could find was pd-ksh [which comes on the discs from RedHat]. The pd-ksh works but it has some limitations, which you have just tripped across. There are other limitations to this implementation of ksh. Check this link:
http://www.cs.mun.ca/~michael/pdksh/NOTES
We pushed back but our vendor insisted on using it, so we finally worked out a deal where the vendor will support any issues with it.
The bash shell seems to be a superset of pd-ksh, so I don't see any reason to use pd-ksh. As Steven mentioned, about the only change is the 'echo' statements. I'd much rather run on a shell that is active and supported. If you check the changelog on the pd-ksh web site, the last version was released in 1999, which doesn't give me a warm feeling for a production system.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2004 07:10 PM
тАО05-31-2004 07:10 PM
Re: Linux ksh (pdksh-5.2.14-21) versus HPUX 11.0 ksh
however some time ago the ksh opened up the source code as well, and you can now get RH packages for it, these are close to 100% compatible. ftp://dan.drydog.com/pub/linux/ksh93-2000.10.31.0-1.i386.rpm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2004 07:16 PM
тАО05-31-2004 07:16 PM
Re: Linux ksh (pdksh-5.2.14-21) versus HPUX 11.0 ksh
Judging from your replies we'll probably be ok with the other scripts. I'll doublecheck any scripts using non-triavial echo statements.
regards,
Johan