I have created a script to mount an usb device and cdrom drive automaticly when its plugged in. I had been trying to get this working with autofs (see https://superuser.com/questions/605896/automount-usb-pen-drive-and-cdrom-drive-on-plugin ) but now trying to work with a script running at boot.
I think the logic is sound but I get line 13: [: missing ']'
The script is:
#!/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
And then script is launched from rc.local using ./path/to/script&
You need a space here:
while [ -b /dev/cdrom]; do
^
_____________________|
There's only a whitespace missing, instead of
while [ -b /dev/sda1]; do
try
while [ -b /dev/sda1 ]; do
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.