validating 10. IP address any way possible


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting validating 10. IP address any way possible
# 1  
Old 02-28-2006
Data 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'
# 2  
Old 02-28-2006
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

C program to detect duplicate ip address if any after assigning ip address to ethernet interface

Hi , Could someone let me know how to detect duplicate ip address after assigning ip address to ethernet interface using c program (3 Replies)
Discussion started by: Gopi Krishna P
3 Replies

2. Shell Programming and Scripting

validating(pingable or not) remote ip address in shell script

i need to verify whether the ip adress given as input to the shell script is pingable or not... that is whether the ip is alive and responding.. ping $ip_adress the above wont work in script because the execution is continuous... so the shell script keeps will dwell in this pinging process...... (8 Replies)
Discussion started by: vivek d r
8 Replies

3. Shell Programming and Scripting

awk for validating

HI, I am trying to write a validation script as below awk '($1=="ABC"&&$2="XYZ" ,then check the value in $8,$10 these columns should not be null. so their should be some corresponding value n the $8 and $10 column,if their is no value the script has to give error saying that at a... (2 Replies)
Discussion started by: gaur.deepti
2 Replies

4. UNIX for Dummies Questions & Answers

Validating a file

Pardon my ignorance but I am lost on how to do this I have a file called "Sample.txt", it is pipe delimited, it should have 13 fields. But some of the records do not, I would like to set up a shell script where I can pass in a parameter "Sample.txt" and it would split the file into records... (2 Replies)
Discussion started by: dgeehot
2 Replies

5. UNIX for Dummies Questions & Answers

Panic kernal-mode address fault on user address 0x14

:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message: PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14 KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD) EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies

6. Shell Programming and Scripting

Validating IP address.

Hi All, This is a small snippet that I am using to validate the format of IP address.This is working fine. Since this is not elegant, please let me know if anyone has a better working code than the one below. Also I am planning to ping the ip address given by the user and check the $?... (3 Replies)
Discussion started by: nua7
3 Replies

7. Shell Programming and Scripting

Validating $1 and $2 before using

Hi there, I'm trying to validate my $1 and $2 before I use them in the sqlplus update, I think I have the validation rules set correctly??? however when I test my script, it jumps straight into the sql. It doesn't seem to validate the vars....even when I know they are incorrect. if ; then ... (6 Replies)
Discussion started by: nhatch
6 Replies

8. UNIX for Dummies Questions & Answers

validating userid

What's wrong with this syntax? It's part of my 'if' statement but it doesn't seem to pass and it keeps going to the 'else' part. I thought it says that userid must start with a non-numeric character and is between 6 and 10 characters long (alphanumeric). $userid|grep -Eq '^?\{6,10\}+$' if... (2 Replies)
Discussion started by: giannicello
2 Replies

9. Programming

validating input

how do i validate y script so that it only accepts values between 1 and 3 and against any character input, cause at the moment i can only validate against numbers outside 1 and 3 but not characters cheers (4 Replies)
Discussion started by: ruffenator
4 Replies

10. Shell Programming and Scripting

validating dates

This is what I have to check date entries in an interactive script with the end users... I use this to build control cards for a reporting utility supplied by a software vendor. I also want to check to make sure its a valid day based on the month (ie 30days has sept, april, june and Nov..)... ... (2 Replies)
Discussion started by: MizzGail
2 Replies
Login or Register to Ask a Question