我已經創建了一個腳本來掛載一個USB設備和光驅自動插入時。我一直試圖讓這與autofs(見https://superuser.com/questions/605896/automount-usb-pen-drive-and-cdrom-drive-on-plugin)工作,但現在試圖與一個腳本在啓動時運行。bash腳本丟失']'錯誤
我認爲邏輯是健全的,但我得到line 13: [: missing ']'
的腳本是:
#!/bin/bash
while true
do
if [ -b /dev/sda1 ]
then
mkdir /media/usb
mount /dev/sda1 /media/usb
while [ -b /dev/sda1]; do
sleep 2
done
umount /media/usb
rmdir /media/usb
fi
if [ -b /dev/cdrom ]
then
mkdir /media/cdrom
mount /dev/sda1 /media/cdrom
while [ -b /dev/cdrom]; do
sleep 2
done
umount /media/cdrom
rmdir /media/cdrom
fi
sleep 5
done
然後腳本是從rc.local的使用./path/to/script&
'而[-b的/ dev/SDA1] =>而[-b的/ dev/SDA1]' –
同樣的問題10行以後在'而[ -b/dev/cdrom];做' – twalberg