Weird Error (: No such file or directory)

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

That looks like you've got carriage returns in your file. They send you to the beginning of the line.

You could probably rewrite your script much more efficiently if we knew the format of your data, but try this band-aid fix meanwhile:

data=`tr -d '\r' < /proc/dahdi/1`
1 Like

You want to prepend an echo on the last line ...

2 Likes

Hi Corona, thanks for the help but that didn't work. :frowning:

Thanks Walter, just what I wanted. Sorted my issue. (Y)