[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
read from characterdevice /dev/isdninfo
From: |
eminderlein |
Subject: |
read from characterdevice /dev/isdninfo |
Date: |
Sun, 22 Oct 2000 20:58:44 +0200 (MEST) |
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCO
NF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64 -I.
-I. -I./lib -I/usr/include -O2 -pipe
uname output: Linux alex 2.2.10 #15 Mit Jul 12 16:11:22 MEST 2000 i686
unknown
Machine Type: i686-pc-linux-gnu
Bash Version: 2.03
Patch Level: 0
Release Status: release
Description:
[Detailed description of the problem, suggestion, or complaint.]
running on SuSE Dist 6.2
try to run a script "isdn_pruefen2"(=isdn_up_test)
it shall read every second or on every dial/hangup request on
/dev/isdninfo and evaluate the strings and
give shell level information, if ISDN is up or it is to initiate a dial
or hangup process, also for cost sharing, how many are
online
(reason : isdnctrl status is not clear about the connection being
established)
see also man isdninfo
quote************************
DESCRIPTION
/dev/isdninfo is a character device with major number 45
and minor number 255. It delivers status information from
the Linux ISDN subsystem to user level.
DATA FORMAT
When reading from this device, the current status of the
Linux ISDN subsystem is delivered in 6 lines of text. Each
line starts with a tag string followed by a colon and
whitespace. After that the status values are appended sep
arated by whitespace.
BLOCKING BEHAVIOUR
After opening the device, at most 6 lines can be read by a
user process. After that, the user process is blocked.
Whenever a status change happens, the process is allowed
to read 6 more lines, starting with line one.
unquote**********************
The script works with regular files,
cp /dev/isdninfo {to_other_file} works as well,
also this creates a mess copying /dev/isdninfo with cat or cp, then
killing the cp or cat into {to_other_file} process before and then
evaluating the {to_other_file} with read
I hate to start with C or c++ for such a small input, I feel it shall
be solved in the bash
I have the book "Learning the bash shell", it does not answer clearly to
this point.
This is my little script:
quote ========================
#! /bin/bash
case $1 in
"")
echo "usage : $0 {Inputfile}"
exit 1
;;
*)
PS4='$0 line $LINENO: '
declare -i za=0 zl=0
declare -a TAG
declare -a ISDNSTATOUTS
#set -o verbose
#set -o xtrace
Eingabe=$1 # (=/dev/isdninfo)
zl=0
while true ; do
za=0
while read TAG[$za] ISDNSTATOUTS[$za] ; do
fehlercode=$?
set -o verbose ; set -o xtrace
echo fehlercode $fehlercode ;
echo TAG ${TAG[$za]}
echo ISDNSTAT ${ISDNSTATOUTS[$za]}
za=$za+1
done < $Eingabe
#done < isdninfo_sequenz
za=0
while [ $(( $za< 6 )) = 1 ]; do
echo za $za ;
echo TAG ${TAG[$za]}
echo ISDNSTAT ${ISDNSTATOUTS[$za]}
za=$za+1
done
zl=$zl+1
echo $zl
sleep 2
done
;;
esac
# end of isdn_pruefen2
unquote ==================
script works well with regular files, but line
while read TAG[$za] ISDNSTATOUTS[$za] ; do
exits with exitcode 1 immediately, if the file is a symlink to or the
characterdevice /dev/isdninfo itself
I did not succeed to work with file descriptors, although this might be
the solution.
PROBLEM
I did not find a clear description whether read by default can or
cannot input from character devices(ro)
QUESTION
How can I read from a character device like the above without leaving
the bash
shell level?
Repeat-By:
run above script between the quotes with your equipment with an ISDN
device
[Describe the sequence of events that causes the problem
to occur.]
Fix: none
[Description of how to fix the problem. If you don't know a
fix for the problem, don't include this section.]
thanks
with the best regards
mit freundlichen GrĂ¼ssen
Erich Minderlein
----------------------------------
E-Mail: eminderlein@netclub.de
E-Mail: eminderlein@locoware.de
www.locoware.de
Date: 22-Oct-00
Time: 20:35:23
This message was sent by XFMail
an ascii mailing ware
Please don't send HTML mail, we don't read all the <>
----------------------------------
quote from
**************************************************
"On the side of the box, under 'System
Requirements', it said 'Requires Windows
95 or better'. So I installed Linux."
**************************************************
----------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- read from characterdevice /dev/isdninfo,
eminderlein <=