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
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
тАО08-06-2005 03:14 PM
тАО08-06-2005 03:14 PM
I want it to accept only eight alphanumeric characters.
10 points for best answer!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2005 11:36 PM
тАО08-06-2005 11:36 PM
Solutionthere are probably many ways of achieving that; you could try something like this:
#!/usr/bin/sh
REST=""
RES=""
message()
{
echo "input 8 alnum chars: \c"
}
message
while [ "$RES" != "OK" ]
do
read INPUT
REST=$(echo "$INPUT" |tr -d "[[:alnum:]]")
if [ "$REST" != "" ]
then
message
else
# continue with count check...
if [ "${#INPUT}" != 8 ]
then
message
else
RES=OK
fi
fi
done
echo "$INPUT" ok, continue with script
regards,
John K.
- Tags:
- read
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 05:57 AM
тАО08-07-2005 05:57 AM
Re: char
echo the string into awk as follow:
echo $AAA | awk '{ A=length($0) } END { if (A == 8) { exit(1) }}'
awk returns 1 if 8 char else return 0
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 06:50 AM
тАО08-07-2005 06:50 AM
Re: char
#!/usr/bin/sh
typeset -i STAT=0
typeset X=""
while [[ ${STAT} -ne 0 ]]
do
echo "Enter value: \c"
read X
echo "${X}" | grep -E -q -e "^[[:alnum:]]{8}$"
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "\aInvalid; re-enter.\n"
fi
done
echo "X = \"${X}\""
This must return exactly 8 alphanumeric characters.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 07:20 AM
тАО08-07-2005 07:20 AM
Re: char
both answers accept alpha?
I want it to accept only aphanumeric characters?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 07:42 AM
тАО08-07-2005 07:42 AM
Re: char
Please explain what you mean with alpha.
Best I know it is a sub-set of alpha-numeric.
So 8 alpha = 8 alpha-numeric.
examples:
abcdefgh
12345678
A1B2C3D3
counter examples:
123 5678
ab%def?h
If need be, give examples of acceptable and not acceptable input.
Here is an other starting point for a solution:
#!/usr/bin/csh
#
set test
while (`echo $test | tr '[:alnum:]' '[x*0]'` != 'xxxxxxxx')
set test=$<
echo "--$test--"
end
any and all alphanumerics in $test are replaced by an 'x' (x*0 = unlimited x's :-)
If the result is 8 x's, the input must have been valid.
fwiw,
hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 05:29 PM
тАО08-07-2005 05:29 PM
Re: char
#!/bin/ksh
echo "Enter input word";
read word;
LEN=$(echo $word | awk '{ print length($1) }')
if [[ ${LEN} -ge 8 ]]
then
ALPLEN=$(echo $word | tr -d '[[:alnum:]]'| awk '{ print length($1) }')
if [[ ${LEN} -eq 8 ]]
then
echo "Entered word $WORD is having 8 alphanumeric characters"
else
echo "Entered word $WORD is not having 8 alphanumeric characters"
fi
else
echo "Entered word $WORD is having less than 8 characters"
fi
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 06:09 PM
тАО08-07-2005 06:09 PM
Re: char
$ cat script
typeset -L8 myVar
echo "Enter value for myVar: \c"
read myVar
echo "myVar is " $myVar
$ ./script
Enter value for myVar: jlfjldjf98df9dskljfsdu
myVar is jlfjldjf
You can add the check for alphanumeric content over top of it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2005 11:15 AM
тАО08-08-2005 11:15 AM