The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > SUN Solaris
Google UNIX.COM


SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-10-2008
Registered User
 

Join Date: May 2008
Posts: 14
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
Reply With Quote
Forum Sponsor
  #2  
Old 06-10-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
Thumbs up check if this helps..

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
Reply With Quote
  #3  
Old 06-11-2008
Registered User
 

Join Date: May 2008
Posts: 14
thanks

its working but i need to ping from this machine to the ip entered by the user.
Reply With Quote
  #4  
Old 06-11-2008
Registered User
 

Join Date: May 2008
Posts: 14
thanks

its working but i need to ping from this machine to the ip entered by the user.
Reply With Quote
  #5  
Old 06-11-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
so where is the problem..? Can you send the error?
Reply With Quote
  #6  
Old 06-11-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
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
There are multiple threads on this site about validating IP addresses; you could look at those, too. Try this canned search:
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0