From owner-freebsd-questions Wed Feb 20 14:19: 6 2002 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-11.mail.nl.demon.net [194.159.73.21]) by hub.freebsd.org (Postfix) with ESMTP id 9DD3B37B400 for ; Wed, 20 Feb 2002 14:19:01 -0800 (PST) Received: from [212.238.194.207] (helo=mailhost.raggedclown.net) by post.mail.nl.demon.net with esmtp (Exim 3.33 #1) id 16df4m-0006FU-00 for questions@freebsd.org; Wed, 20 Feb 2002 22:19:00 +0000 Received: from angel.raggedclown.net (angel.raggedclown.intra [192.168.1.7]) by mailhost.raggedclown.net (Ragged Clown Mail Gateway [buffy]) with ESMTP id A38C913040 for ; Wed, 20 Feb 2002 23:18:59 +0100 (CET) Received: by angel.raggedclown.net (Ragged Clown Host [angel], from userid 6002) id 91B8322590; Wed, 20 Feb 2002 23:18:59 +0100 (CET) Date: Wed, 20 Feb 2002 23:18:59 +0100 From: Cliff Sarginson To: questions@freebsd.org Subject: Re: BASH programming question Message-ID: <20020220221859.GA2006@raggedclown.net> References: <5.1.0.14.2.20020220160637.02763050@pop.earthlink.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5.1.0.14.2.20020220160637.02763050@pop.earthlink.net> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Feb 20, 2002 at 04:17:57PM -0500, B.K. DeLong wrote: > Hey all - > > I'm somewhat new to the world of BASH scripting. I'm trying to write a > script that I can throw in cron to check if my IP has changed. However, I'm > having problems with the variable. What I'm trying to say, is "if $IP is > not null then email me" > > ie. if diff produces no results, then the IP is the same. > > However, I can't quite figure out the way to define this without getting a > "too many arguments" error. > > #!/usr/local/bin/bash -x > ifconfig | grep "inet " | cut -f2 -d" " | grep 24. > /.newip > IP='diff /.newip /.currentip' Your quotes are the wrong way around.. You need ` not ' And "not equal to" is "!=" and ... "null" , is that built into bash ? I think not, try "". Also you should get into the habit of using $ vars in {} to avoid errors if they have a NULL value, i.e. ${IP} Also the "cool" way to do this is to actually check the exit code from diff "$?", if it is zero then no differences were found. -- Regards Cliff Sarginson -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message