V
V
vandalizm1232019-07-22 16:05:18
linux
vandalizm123, 2019-07-22 16:05:18

How to run a script for linux Centos7 without errors?

Good day. Faced such a problem. I'm testing a zabbix monitoring system. I'm trying to connect Asterisk 13 to a trunk monitoring system. I found on the site https://serveradmin.ru/monitoring-asterisk-v-zabbix/ a link to a script for monitoring sip trunks. When running the script, an error occurs
5d35b3e81c77a766025564.jpeg
Script in use

#!/bin/bash

# Получаем количество всех транков в системе
total=`sudo asterisk -rx 'sip show registry' | sed -n '/registrations/p' | awk '{print $1}'`
# Получаем число активных транков
active=`sudo asterisk -rx 'sip show registry' | sed -n '/Registered/p' | wc -l`
# Получаем имена транков с проблемам
offline=`sudo asterisk -rx 'sip show registry' | sed -n '/Request\|Rejected\|Authentication\|Auth/p' | awk '{print $3}'`
# Сравниваем общее число с числом активных транков и выводим сообщение об их состоянии
if [ $active -lt $total ]
then
echo Trunks offline $offline
else
echo All trunks are online
fi

Help solve this problem

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2019-07-22
@vandalizm123

remove the screw line endings from the file - you see the ^M error in the text.
remove for example using dos2unix
dos2unix file.txt

V
vreitech, 2019-07-22
@fzfx

which bash?

V
vandalizm123, 2019-07-22
@vandalizm123

5d35ba437e736950862038.jpeg
Ran every error

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question