The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
validating data joanneho Shell Programming and Scripting 1 10-08-2006 09:03 AM
Validating date in sas radhika03 Shell Programming and Scripting 1 09-16-2005 02:33 AM
Validating $1 and $2 before using nhatch Shell Programming and Scripting 6 09-17-2003 10:01 AM
validating input ruffenator High Level Programming 4 04-24-2002 05:30 AM
validating dates MizzGail Shell Programming and Scripting 2 03-05-2002 01:34 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-28-2006
Registered User
 

Join Date: Feb 2006
Posts: 3
Unhappy validating 10. IP address any way possible

HELP: validating IP addresses any way possible

--------------------------------------------------------------------------------

I am trying to validate input from the user in a script. I thought is was easy to do using regular expressions but I can't figure out how to use REs in a conditional. I have tried using grep from a temp file, sed from a temp file, sed from command line, comparison in an if condition and I cannot figure it out and I don't have much hair left! i am trying to validate input of an IP address.


Thanks for your help

OK I have tried the following expressions that according to the regex tool match IP addresses, but they all seem to flip flop back and forth for valid and not valid IPs and the entire list albeit 2 or 3 are valid. What is the deal. I would gladly do this another way if anyone could steer me in the right direction. Thanks greatly for your help!!
rc=`egrep -c "[0-9][13]\.[0-9][13]\.[0-9][13]\.[0-9][13]"`

rc=`egrep -c \\b\(?:\(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\
\.\){3}\(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\b"`

rc=`egrep -c '\\b\(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\.\(2
5[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\.\(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\.\(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\b'

rc=`egrep -c '10.\([781]|70|80\).\(25[0-5]|2[0-4][0-9]|[01]?[0-
9][0-9]?\)\\.\(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\)\\b'
Forum Sponsor
  #2  
Old 02-28-2006
Registered User
 

Join Date: Dec 2005
Location: London
Posts: 222
Moderator,

Please close this thread, the same user posted the same question yesterday in shell programming section and I have replied for that... without checking or replying to that he posted again here.... not following the rules by duplicating the messages.

It is waste of time replying to this kind of users anymore...

Thanks..Mahendra.
Google The UNIX and Linux Forums
Closed Thread

Tags
regex, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:27 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