Why do I get a "Permission denied" error with the following script:
#!/bin/sh if [ -z $1 ]; then echo "no argument given" exit 1 fi for i in /sys/class/rc/rc*; do if [ -e "$i/device/driver/$1" ]; then number=echo $i | sed 's%/sys/class/rc/rc([0-9]+)%$0%' echo "found $number" fi done
What I would expect to happen is that $number contains the "digit" value of the path /sys/class/rc/rc[0-2], instead, the "echo" command seems to try to cat the file /sys/class/rc/rc[0-2].
In particular, if /sys/class/rc/rc1/device/driver/pwm-ir-transmitter exists, the output of
/usr/local/sbin/lircprobe: 10: /usr/local/sbin/lircprobe: /sys/class/rc/rc1: Permission denied
(lircprobe is the name of the script, above)