Vale sempre colocar o caminho completo até os scripts e arquivos se não for rodar a partir do diretório!
# Linha SIP
LINHA1=$(asterisk -rx 'sip show registry'|grep "9238899646"|cut -c 71-91);
# Grupo telegram
GRP="-241406789"
# ASSUNTO EMAIL
ASSUNTO="Alerta-Status Linhas SIP"
# Alerta o jsilva
# Checa se o status da linha é diferente de registrada
# Se estiver fora Alerta no Email e telegram
# Caso contrario so gera o log e da um Ok no telegram
# Obs. Eu chamei o script "telegram.sh" de formas diferentes justamente para testar se pela funcao ou da forma comum.
if [ $LINHA1 != "Registered" ]; then
echo 'Linha LINHA1 Nao Registrada!' >/tmp/monitorasip.txt
echo 'Linha LINHA1 Nao Registrada!' | logger
cat /tmp/monitorasip.txt | mail -s 'IPBX - Alert Linha SIP LINHA1 Down!' -r
address@hidden $EMAIL_TO
$run_telegram \"$GRP\" \"$ASSUNTO\" \"Linha LINHA1 Down!\"
else
echo "Linha LINHA1 Registrada" | logger
telegram a | logger
fi