- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- input has 2 .'s or none, but is an int in either c...
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
Forums
Discussions
Discussions
Discussions
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
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
10-09-2001 03:59 AM
10-09-2001 03:59 AM
Relating to this question,
http://forums.itrc.hp.com/cm/QuestionAnswer/1,11866,0x58fec6af36b7d5118ff10090279cd0f9,00.html
I'm attempting to put the two possible functions into one script and based on input run the appropriate command.
ie
./script 1.1.10
(script recognises this has 2 periods in it and sets VALUE=1
./script 65892
(script recognises this has not got . in it and sets value=2
./script abcd
(script recognised this is not numerical and sets value=3
I've seen posts like this (IP address scripts) and some on linux, but can't find them for the moment.
Best ways to do this?
Later,
Bill
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2001 04:11 AM
10-09-2001 04:11 AM
Re: input has 2 .'s or none, but is an int in either case!
-------------cut here --------------
#!/bin/sh
read input
OLDIFS=$IFS
IFS=.
set -- $input
echo $1 $2 $3
if [[ ! -n $2 ]]
then
case $1 in
+([0-9]))
echo "One integer value $1"
break
;;
*)
echo "One non-integer value $1"
break
;;
esac
fi
-------------cut here --------------
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2001 04:12 AM
10-09-2001 04:12 AM
Re: input has 2 .'s or none, but is an int in either case!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2001 04:21 AM
10-09-2001 04:21 AM
Re: input has 2 .'s or none, but is an int in either case!
Thanks anyway.
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2001 04:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2001 04:38 AM
10-09-2001 04:38 AM
Re: input has 2 .'s or none, but is an int in either case!
----cut here----
#!/bin/sh
input=$1
OLDIFS=$IFS
IFS=.
set -- $input
let VALUE=1
if [[ ! -n $2 ]]
then
case $1 in
+([0-9]))
VALUE=2
break
;;
*)
VALUE=3
break
;;
esac
fi
echo $VALUE
----cut here----
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2001 04:42 AM
10-09-2001 04:42 AM
Re: input has 2 .'s or none, but is an int in either case!
All that validations are done by shell scripting.
And for all that like learn shell script programming, try to read installation scripts of drivers on SCO.
Good Luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2001 08:57 AM
10-09-2001 08:57 AM
Re: input has 2 .'s or none, but is an int in either case!
even if I am the only one using "case" it still
seems easiest to me that way:
case "$1" in
*.*.*) exit 1;;
*[^0-9]*) exit 3;;
*) exit 2;;
esac
but I am not logged into a UN*X system,
so it might not work...
Regards,
Wodisch