I have one dvb-t and one dvb-s card in my system which are in
/dev/dvb/adapter0
and
/dev/dvb/adapter1
Is there a way to find out which card is currently working? and which one isn't?
I have one dvb-t and one dvb-s card in my system which are in
/dev/dvb/adapter0
and
/dev/dvb/adapter1
Is there a way to find out which card is currently working? and which one isn't?
You can use lsof to see which processes are using a file. In your case:
$ lsof /dev/dvb/adapter0
$ lsof /dev/dvb/adapter1
Each call will give you a list of the processes having requested a handler (file descriptor) to your device. If nothing is printed, you can conclude that your device is not currently in use. Here's an example with /dev/urandom, used by Conky, Chromium and Thunderbird on my system:
$ lsof /dev/urandom
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
conky ---- ---- 3r CHR 1,9 0t0 1034 /dev/urandom
chromium- ---- ---- 55r CHR 1,9 0t0 1034 /dev/urandom
thunderbi ---- ---- 24r CHR 1,9 0t0 1034 /dev/urandom
r (in the FD field) means that the processes have requested read access: the number just before that is their descriptor number. CHR and 1,9 are the device type and major/minor numbers. 0t0 is the current file offset for that descriptor, and 1034 is the device file's inode number (on my system).
For more information about this output, see lsof(8). By the way, lsof returns a different status code depending on whether it found processes for a file or not. This means you can use it quite simply in a shell script:
#!/bin/bash
if lsof /dev/dvb/adapter0 > /dev/null 2>&1; then
echo "Adapter 0 is in use."
elif lsof /dev/dvb/adapter1 > /dev/null 2>&1; then
echo "Adapter 1 is in use."
else
echo "No adapter is in use."
fi