- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- question about if and elif statements
Operating System - HP-UX
1753681
Members
5955
Online
108799
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО08-31-2004 06:09 AM
тАО08-31-2004 06:09 AM
I having some trouble running a script with several elif statments.
I believe the problem lies in "[]' or in the setting of the read varable.
Script is attached below
elif start on line 176 of 453.
The stript works, I just can't seem to get the right message display when you don't choose a number.
I believe the problem lies in "[]' or in the setting of the read varable.
Script is attached below
elif start on line 176 of 453.
The stript works, I just can't seem to get the right message display when you don't choose a number.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2004 06:26 AM
тАО08-31-2004 06:26 AM
Solution
David,
With a quick look at the script, I can suggest you a couple of things
1) If you want to test for null input, -z option with test is preferred than comparing the input against ''.
Try
if [[ -z "$SNUM" ]]
then
echo "NADA!!"
else
echo "Something"
fi
2) elif [[ "$SNUM" < 1 ]]
You should use the operator -le than <.
elif [[ "$SNUM" -lt 1 ]]
-- Sundar
With a quick look at the script, I can suggest you a couple of things
1) If you want to test for null input, -z option with test is preferred than comparing the input against ''.
Try
if [[ -z "$SNUM" ]]
then
echo "NADA!!"
else
echo "Something"
fi
2) elif [[ "$SNUM" < 1 ]]
You should use the operator -le than <.
elif [[ "$SNUM" -lt 1 ]]
-- Sundar
Learn What to do ,How to do and more importantly When to do ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2004 06:50 AM
тАО08-31-2004 06:50 AM
Re: question about if and elif statements
I run the script. I put in a letter "s" to see what would happen is user put in a letter. Below ins the result:
Please enter START Number (1 - 15) or (E) to Exit: [s ]
s
/usr/contrib/tools/chkimgprnt.sh[24]: [[-z: not found.
/usr/contrib/tools/chkimgprnt.sh[24]: s: The specified number is not valid for t
his command.
ASLO used a number and got:
Please enter START Number (1 - 15) or (E) to Exit: [5 ]
s
/usr/contrib/tools/chkimgprnt.sh[10]: [Aa-Za]: Syntax error
ccchpl(/usr/contrib/tools)#
Please enter START Number (1 - 15) or (E) to Exit: [s ]
s
/usr/contrib/tools/chkimgprnt.sh[24]: [[-z: not found.
/usr/contrib/tools/chkimgprnt.sh[24]: s: The specified number is not valid for t
his command.
ASLO used a number and got:
Please enter START Number (1 - 15) or (E) to Exit: [5 ]
s
/usr/contrib/tools/chkimgprnt.sh[10]: [Aa-Za]: Syntax error
ccchpl(/usr/contrib/tools)#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2004 06:59 AM
тАО08-31-2004 06:59 AM
Re: question about if and elif statements
[[-z: not found.
There should be a space after [[ and -z
There should be a space after [[ and -z
Learn What to do ,How to do and more importantly When to do ?
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP