LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-30-2007, 03:06 PM   #1
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slackware, debian, ubuntu
Posts: 666

Rep: Reputation: 39
a script to match 2 ip strings


hello everyone,
shouldn't this script return true if the ip addresses match?

Code:
#!/bin/bash

TESTIP=192.168.0.1
echo "=$TESTIP"
HOSTIP=`host synthnassizer.no-ip.org | grep -Eo \([0-9]\{1,3\}.\)\{3\}[0-9]\{1,3
\}`
echo "=$HOSTIP"
if [ TESTIP = HOSTIP ]; then
        echo "they are the same"
else
        echo "they are different"
fi
it always returns 'they are different' to me even though echoing them makes them look alike...
thank you for your help
nass
 
Old 05-30-2007, 03:15 PM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Bah, just saw it:

Code:
if [ TESTIP = HOSTIP ]; then
should be

Code:
if [ $TESTIP = $HOSTIP ]; then
Common mistake, I make it all the time

Last edited by H_TeXMeX_H; 05-30-2007 at 03:16 PM.
 
Old 05-30-2007, 03:49 PM   #3
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slackware, debian, ubuntu
Posts: 666

Original Poster
Rep: Reputation: 39
heh indeed
thanks for noting that...
from the 1st moment bash looked so ichy!
still loving it
nass
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script Strings - trim revof11 Programming 3 11-30-2006 09:46 AM
Shell script to compare blocks of strings? bruno buys Programming 10 04-15-2006 02:16 PM
script to exclude strings... NiallC Programming 10 03-28-2005 06:46 PM
Help with a script (question on strings) wswartz Linux - General 3 07-11-2004 08:53 AM
Formatted Strings in Script File mhjones Programming 1 06-07-2004 10:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration