- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: If loop in the Korn Shell in HP Ia 64
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
тАО11-05-2007 12:24 AM
тАО11-05-2007 12:24 AM
I am trying to write a small shell script in HP UX Ia64.
read Option
if [ $option == 1 ]; then
echo One
else
echo Two
fi
But, it says
== unknown test operator
But i think we should use == for korn and
if ( $Option eq 1 )
for csh and tcsh.
Can any one Please Correct me where i am going wrong.
thanks in advance
Vikram
Solved! Go to Solution.
- Tags:
- Test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2007 12:29 AM
тАО11-05-2007 12:29 AM
Solutionregards,
ivan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2007 12:30 AM
тАО11-05-2007 12:30 AM
Re: If loop in the Korn Shell in HP Ia 64
Try double square braces:
if [[ $option == 1 ]]; then
echo One
else
echo Two
fi
HTH
Duncan
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2007 12:32 AM
тАО11-05-2007 12:32 AM
Re: If loop in the Korn Shell in HP Ia 64
The manpages for 'test(1)' will guide you.
Remember, if you are using '/usr/bin/sh' as your script interpreter, then you are using the HP-UX POSIX shell --- a superset of the Korn88 provided in '/usr/bin/ksh' by HP.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2007 02:16 AM
тАО11-05-2007 02:16 AM
Re: If loop in the Korn Shell in HP Ia 64
thank you very much for the reply.
Ivan's solution is working fine for me.
Also before closing the thread i request Ivan to send the similar links for Tcsh and csch shell scripting if they are existing .
I tried going back in the present link but it seems only ksh and awk scripting is present in the link.
thanks and regards
Vikram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2007 02:23 AM
тАО11-05-2007 02:23 AM
Re: If loop in the Korn Shell in HP Ia 64
regards,
ivan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2007 03:32 AM
тАО11-05-2007 03:32 AM
Re: If loop in the Korn Shell in HP Ia 64
use the variable reference in double quotes - so there will be no syntax error, when it is completely unset:
if [ "$option" = 1 ]
then
...
Same construct for tcsh/csh:
if ("$option" == 1) then
echo One
else
echo NOT-One
endif
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2007 05:39 AM
тАО11-05-2007 05:39 AM
Re: If loop in the Korn Shell in HP Ia 64
if [ $option -eq 1 ]; then
echo One
else
echo Two
fi
I prefer to use -eq (and relatives like -ne -gt -le ...) for numbers even though some string comparisons will work. The problem with string compares is that they won't check invalid numbers and magnitude comparisons such as > or < can have unexpected results.
For simple actions, you can simplify the test to a one-liner like this:
[ $option -eq 1 ] && echo One || echo Two
The man page for ksh is helpful here.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2007 11:28 PM
тАО11-07-2007 11:28 PM
Re: If loop in the Korn Shell in HP Ia 64
If you have found a solution, please assign points and close this thread. Thanks!
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-08-2007 01:12 AM
тАО11-08-2007 01:12 AM
Re: If loop in the Korn Shell in HP Ia 64
Pete
Pete