Originally Posted by
blm-ubunet
James
The format of this is wrong:
Code:
if [ "$ID_CDROM_MEDIA_DVD"="1" ]
change all similar instances like to style/format of below
Code:
if [ $ID_CDROM_MEDIA_DVD = "1" ] or
if [ "$ID_CDROM_MEDIA_DVD" = "1" ] or
if [ $ID_CDROM_MEDIA_DVD == "1" ]
Without the space, I believe it tests the return value of assignment (always true).
So your script was going to return just dvd.
You made a mess of the first line of script as well:
I have found this to be a very useful resource:
http://www.tldp.org/LDP/Bash-Beginne...ect_07_01.html
Well well well!!
blm-ubunet your advice is well taken, I have changed the construction of the 'if' statements to match and it is now working! , thank you.
Keith_Helm I cant thank you enough for the posix code, this will enable me to further look into this. Thank you.
Udev rule as follows:
Code:
# ID_CDROM_MEDIA_BD = Bluray
# ID_CDROM_MEDIA_DVD = DVD
# ID_CDROM_MEDIA_CD = CD
ACTION=="change", SUBSYSTEMS=="scsi", KERNEL=="s[rg][0-9]*", ATTRS{vendor}=="TSSTcorp", ENV{ID_CDROM}=="?*", MODE="0660", GROUP="optical", RUN+="/usr/local/bin/DiscTypeTest3.sh"
links to script as follows
Code:
#!/bin/bash
# ID_CDROM_MEDIA_BD = Bluray
# ID_CDROM_MEDIA_DVD = DVD
# ID_CDROM_MEDIA_CD = CD
MEDIA=
if [ $ID_CDROM_MEDIA_DVD = "1" ]
then
MEDIA=dvd
(
echo "$MEDIA" >> "/var/log/DiscTypeTest.log"
) &
elif [ $ID_CDROM_MEDIA_CD = "1" ]
then
MEDIA=cdrom
(
echo "$MEDIA" >> "/var/log/DiscTypeTest.log"
) &
fi
(set -o posix ; set) > "/var/log/DiscTypeTestVariables.log"
produces the following output in
Code:
/var/log/DiscTypeTest.log
when an audio CD is inserted and then a dvd afterwards
Code:
cdrom
cdrom
dvd
dvd
SOLVED
Bookmarks