#!/bin/sh PATH=/bin:/usr/bin:/sbin:/usr/sbin GREP="/bin/grep" HCI_CONFIG=/usr/bin/hciconfig echo "Check for Bluetooth device status" if (${HCI_CONFIG} | ${GREP} hci); then echo "Bluetooth device is UP" ${HCI_CONFIG} hci0 up else echo "Did not attach HCI" exit 1 fi TIMEOUT=20 for (( i=1; i<=$TIMEOUT; i++)) do /bin/sleep 0.1 if [ $i -eq $TIMEOUT ] then echo "time expired happen $i" exit 2 fi if (${HCI_CONFIG} | ${GREP} UP); then echo "Bluetooth device is made" break fi echo "Continue...$i" done exit 0