Quantcast
Channel: Allmon - AllStarLink Discussion Groups
Viewing all articles
Browse latest Browse all 87

Bash script for checking connection / reconnect

$
0
0

Has anyone got a working bash script they could share for checking if a node is connected, and then reconnecting if it is not? I have found an example on the forum (below) but this one does not seem to work.

If anyone can share a working script, I would be very grateful!

73
Robert

date >> /usr/sbin/cron_check.txt
CHK=
echo “Checking if connected to the hub”

CHK= asterisk -rx "rpt nodes 537101" | grep -c "51288"
echo $CHK >> /usr/sbin/cron_check.txt

if [ $CHK -eq 1 ]
then
echo “OK, Connected.”
echo “OK, connected.” >> /usr/sbin/cron_check.txt
else
echo “Reconnecting.”
echo “Reconnecting.” >> /usr/sbin/cron_check.txt
asterisk -rx “rpt cmd 537101 ilink 3 51288”
fi

#End

It throws out the error:

“Checking if connected to the hub”
1
./autoconnect.sh: line 8: [: =: unary operator expected
“Reconnecting.”
No such command '“rpt' (type 'core show help “rpt' for other possible commands)

8 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 87

Trending Articles