[wplug] BASH question

Wise, Jeremey WISEJ at PIOS.com
Wed Jul 9 14:59:57 EDT 2003


Another stupid question. I am trying to write a script that detects if a DSL
line is down if it is start it. If the IP rotates email it to me so I can
know how to get to it if I need to.

***************
#!/bin/bash
# Script to bring up Landmark's Internet
# 07-09-2003
# v0.1
Internetstatus="adsl-status |grep up|cut -f 4 -d ' '"
InternetIP="ifconfig ppp0 |grep inet |cut -f 2 -d : |cut -f 1 -d ' '"
curDate=`date +"%y-%m-%d"`
curTime=`date +"%H%M"`

if $Internetstatus=up ;then
   printf The Internet link is up!
      if [! $InternetIP=(cat /root/CurrentIP.txt)] ;then
       echo $InternetIP >/root/CurrentIP.txt
       echo $InternetIP |mail -s "New IP Address" wisej at pios.com
      fi
   ;else
   echo The Internet link is down:$curDate-$curTime >>/var/log/messages
fi
****************

My issues are
1) I can run the command "ifconfig ppp0 |grep inet |cut -f 2 -d : |cut -f 1
-d ' '" at a shell prompt and get an ok response but it does not run. I
tried to put it in brackets (subshell) but that does not work either
2) Logic does not hold; " if [! $InternetIP=(cat /root/CurrentIP.txt)]
;then". How does one do this? How can I check a string output against an
existing variable string or integer?

Thanks,

Jeremey Wise (440)-519-6006
(CNE,MCSE,CSE)
Pioneer-Standard Electronics, Inc
wisej at pios.com




More information about the wplug mailing list