prpr
Well-Known Member
So now all that is needed is to tie that into the output of /proc/mounts...See my edit above.
Yes, I found it in the meantime, but it was the wrong avenue...Humax uses 'mdev' for hotplug BTW.
So now all that is needed is to tie that into the output of /proc/mounts...See my edit above.
Yes, I found it in the meantime, but it was the wrong avenue...Humax uses 'mdev' for hotplug BTW.
#!/bin/sh
cd /sys/bus/usb/drivers/usb-storage
for drv_id in *:* ; do
[ ! -h "$drv_id" ] && continue
for device in /sys/block/sd*/device; do
if echo $(readlink -f $device)|egrep -q "$drv_id"; then
dev_id=`echo $device | cut -f4 -d/`
mount=`grep "^/dev/$dev_id" /proc/mounts|cut -d\ -f2`
echo -n "$drv_id is bound to $dev_id"
if [ -z "$mount" ]; then
echo " (Not mounted)"
echo -n "$drv_id" >unbind
echo -n "$drv_id" >bind
else
echo " (Mounted at $mount)"
fi
fi
done
done
1-2:1.0 is bound to sda (not mounted)
egrep: bad regex '*:*': Invalid preceding regular expression
No, it's an artefact of how the shell's globbing works. I've modified the script...I ran usbscan again and got the following message:This HDR-FOX is currently recording. Is that the problem?Code:egrep: bad regex '*:*': Invalid preceding regular expression
Pilloried for saying that the requirement spec is the raison d'être? I should think so.Which is what I suggested in post #9, and got pilloried for.
Interesting - must be an ash/busybox extension to the test command.Yep, that'll work. Monty should now update his script with the new improved version.
Edit: Just tried it and it worked fine without the quotes but no harm in putting them in.
#!/bin/sh
mount=
if [ -z $mount ]; then
echo empty
else
echo not empty
fi
humax# ./s
empty
nero% ./s
./s: test: argument expected
zsh: exit 1 ./s
Requirement spec ? Reason for existing ? Your not making any sense. WTF are you wittering on about ?Pilloried for saying that the requirement spec is the raison d'être? I should think so.
If I understood what you were on about I wouldn't have asked. Diagrams are good, plain English is even better. Just say what you mean.Jeez - do you need a diagram? Maybe I should code it in C (not my forte).
Under what circumstances will the wildcards not be expanded properly when globbing folder contents ?No, it's an artefact of how the shell's globbing works. I've modified the script...
Yes please. I don't know WTF you are talking about either. But in plain English please.Jeez - do you need a diagram? Maybe I should code it in C (not my forte).
Thanks for that. Before I posted last night I had tried the script with no USB drives attached and did not get any error. Don't like inconsistencies so had another look at the script this morning and I realized that I had earlier replaced the egrep command with a simple grep, since the command argument did not require extended pattern matching. grep does not generate the error, but egrep, or grep -E, does. Mystery solved, but good practice to have the extra test at the start of the loop anyway.When there is nothing to match the pattern - it doesn't expand to nothing, it just stays as is, so you get one trip round the loop with the pattern as the argument.
I've added something to the web interface that will appear in the next version [now available]. Thanks due to prpr and raydon for putting the pieces together.