Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP ABOUT THIS SCRIPT

Status
Not open for further replies.

aoroca

IS-IT--Management
Oct 3, 2003
39
CO
I need info why don work properly myscript...

I appreciate your time !!

#!/usr/bin/ksh
AL=10.2.78.36 # PC Alex

path=$HOME/Alex
arriba="1"
date=`date -u`
while [ $arriba ]
do
a=`netstat | grep smpp | grep $AL | grep ESTABLISHED`
if [$arriba -eq 1]
then
if [ -z "$a" ]
then
MESG="SMSC: Avisor TELEDATOS ($AL) is UP"
for MOBILE in `cat $path/mobiles.txt`
do
print submit\n$MOBILE\n\n5710000001\n\n\n\n\n1\n\n\n\n\n\n\n$MSG\ny\nexit\n\"
| sms_operator > /dev/null 2>&1
sleep 1
done
echo "`date` SMSC: Avisor TELEDATOS ($AL) is DOWN" >> $path/NetLogChk
arriba=0
fi
fi
if [$arriba -eq "0"]
then
if [ -n "$a" ]
then
MESG="SMSC: Avisor TELEDATOS ($AL) is DOWN"
for MOBILE in `cat $path/mobiles.txt`
do
print submit\n$MOBILE\n\n5710000001\n\n\n\n\n1\n\n\n\n\n\n\n$MSG\ny\nexit\n\"
| sms_operator > /dev/null 2>&1
sleep 1
done
echo "`date` SMSC: Avisor TELEDATOS ($AL) is DOWN" >> $path/NetLogChk
arriba=1
fi
fi
sleep 1
done
 
At line 21 an 35 script has failed... some ideas ?
 
Make sure that there are spaces either side of your square brackets...

not: if [$arriba -eq 1]
use: if [ $arriba -eq 1 ]
 
Ygor, thanks for your time.

I have a question, at the script when I execute print command, I need only one time performe it, but this stay in loop, How I can execute one time, stop process, but don abort the script ?
 
I guess you could use "head -1" instead of "cat".
 
Ygor, The mobiles.txt have some MobileNumbers then if I will use head -1, only send short messages to 1st mobile #.

Its possible put a loop before PRINT command until I change ARRIBA variable ?
 
I'm still not sure I understand exactly. Do you mean to replace lines 34&35....

fi
if [ $arriba -eq "0" ]

....with....

elif [ $arriba -eq "0" ]

....?
 
Ygor, let me explain my project:

The script would check IP connections on port # 6200 (SMPP -> to send short messages to mobiles).

I have a file with all mobiles to report events (mobiles.txt)

I wish report when SMPP port is down an recovery form IP ADD Client. and when script execute PRINT (willsend sms to mobiles) but I need perform the job only one time and change ARRIBA variable in order to continue checking until IPADD get UP.
 
Still don't understand entirely, perhaps change

while [ $arriba ]

...to...

while [ arriba -eq 1 ]
 
Sorry about the typo!

...to...

while [ $arriba -eq 1 ]
 
Ygor, but when ARRIBA = 1, the script is exiting and I don want that.
 
use "while [ 1 ]" to keep the script executing continuously.

I love deadlines. I like the whooshing sound they make as they fly by - Douglas Adams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top