![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems . |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
hi all
i need a script to validate a IP address entered by the user by pinging once to the entered IP in solaris..pls help me
|
| Forum Sponsor | ||
|
|
|
|||
|
Check if this helps..
Code:
#!/bin/ksh
echo input IP address
read IP
result=`echo $IP | awk -F"\." ' $0 ~ /^([0-9]{1,3}\.){3}[0-9]{1,3}$/ && $1 <=255 && $2 <= 255 && $3 <= 255 && $4 <= 255 '`
echo $result
|
|
|||
|
nua7: That's a useless use of backticks, and also does not actually ping the address.
In fact, you should probably get a reasonable response from ping if the address is invalid. Code:
vnix$ ping -c 1 999.999.999.999 ping: unknown host 999.999.999.999 http://www.unix.com/cfmgoogle.php?cx...ress&sa=Search PS. Please use a topic which summarizes the contents of your posting. A good topic would also automatically bring a list of "similar threads" which you could explore. Last edited by era; 06-11-2008 at 12:31 AM. Reason: Thread moved on while I was composing; minor updates to my text |
|||
| Google The UNIX and Linux Forums |