who is noemie lenoir dating - Validating an ip address in a bash script

In the meantime I have used a large number of Raspberry Pis for measuring and monitoring purposes.

validating an ip address in a bash script-81

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! 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. I would gladly do this another way if anyone could steer me in the right direction. rc=`egrep -c "[0-9][13]\.[0-9][13]\.[0-9][13]\.[0-9][13]"` rc=`egrep -c \\b\(?

if you don't use anything other than what is documented therein you will have pure shell code.

the main effort with shell code programming is, as with all other programming, defining the problem well and good familiarity with the language.

= "$STOREDIP" ]; then RESPONSE=$(curl -s -k -u $USERNAME:$PASSWORD --user-agent "$USERAGENT" "https://dynupdate.no-ip.com/nic/update?

hostname=$HOST&myip=$NEWIP") RESPONSE=$(echo $RESPONSE | tr -cd "[:print:]") RESPONSE_A=$(echo $RESPONSE | awk '') case $RESPONSE_A in "good") RESPONSE_B=$(echo $RESPONSE | awk '') LOGTEXT="(good) DNS hostname(s) successfully updated to $RESPONSE_B." ;; "nochg") RESPONSE_B=$(echo $RESPONSE | awk '') LOGTEXT="(nochg) IP address is current: $RESPONSE_B; no update performed." ;; "nohost") LOGTEXT="(nohost) Hostname supplied does not exist under specified account.regardsfrom -- laura fairhead # [email protected] if you are bored crack my sig.1F8B0808CABB793C0000666667002D8E410E83300C04EF91F2877D00CA138A7A EAA98F30C494480157B623C4EF1B508FDED1CEFA9152A23DE35D661593C5318E 630C313CD701BE92E390563326EE17A3CA818F5266E4C2461547F1F5267659CA 8EE2092F76C329ED02CA430C5373CC62FF94BAC6210B36D9F9BC4AB53378D978 80F2978A1A6E5D6F5133B67B6113178DC1059526698AFE5C17A5187E7D930492 wrote: What are you trying to validate, just that the input is a potentially valid IP address? if perl -MSocket -e '$addr=unpack("B*",inet_aton(shift)); exit 1 unless ($addr =~ /1/)' $IPADDR; then echo good address else echo bad address fi This has the advantage that things like 192.1 will fail.-- -([email protected])-(0.08|0.26|0.37)-(|Wed Apr 10)- cat ~/. It's a damn poor mind that can only think of one way to spell a word.- Andrew Jackson UIN=66618055 divulged: ``man $'' seriously.IPADDR=192.168.10.1 echo "IP address variable is: $IPADDR" # if [ awk '' "$" ]; then #hopefully this evaluates to true printf "correct ip address" else printf "wrong ip address\n" fi Thanks for any help w/ this, Tom There are 2 wayz to get the variable into the 'awk' script, one is to interpolate it directly by dropping out of single quotes, going in to double ones (just to be on the safe side, leaving IPADDR unquoted in this case should also work thou`) putting your variable there (so the shell replaces that part) and then going back,eg; echo "IP address variable is: $IPADDR" # # the shell will interpolate the variable value of IPADDR # here since it's only in double quotes # vvvvvvvvv awk '{ ip='"$IPADDR"'; split (ip,quad,"."); for (i=1;i255) Another VERY important thing isto check the number of fields that split() gives you is exactly 4, otherwise you could be checking any old data (in the fields outside those returned).

Tags: , ,