Hi Everyone,
I am trying to make this script to use, to find out the DAHDI channel status. Every thing works fine, I even get proper results, however I have this weird error that comes along.
Can someone please help me. Thanks a lot.
#!/bin/bash
# Color to set the test to when a channel is down (red or green)
# ---------------------------------------------------------------
TESTCOL="red"
COLOR="green"
data=`cat /proc/dahdi/1`
chandata=`echo "${data}" | sed -e 's/\t//' -e 's/ \+//' | grep ^[1-4]`
card=`echo "${data}" | grep ^Span`
# -----------------------------------------------
IFS=$'\n'
for channel in ${chandata}; do
curcolor="green"
chinfo=`echo ${channel} | cut -d' ' -f1-3`
status=`echo ${channel} | grep -i "red" 2>&1`
if [ ! -z ${status} ]; then
curcolor=${TESTCOL}
COLOR=${TESTCOL}
fi
MSG="${MSG}
Channel:${chinfo} ${curcolor}
"
done
unset IFS
# -----------------------------------------------
# Prepend the administrative message to the report
# add the card information, the channel statuses
"${COLOR} ${card} ${MSG}"
Result is as following....
[root@PBX~]# ./dahdi.sh
./dahdi.sh: line 31: red Span 1: WCTDM/0 "Wildcard A4B" (MASTER)
Channel:1 WCTDM/0/0 FXSKS green
Channel:2 WCTDM/0/1 FXSKS green
Channel:3 WCTDM/0/2 FXSKS red
Channel:4 WCTDM/0/3 FXOKS green
: No such file or directory