« kdy: 03 Června 2008, 15:49:33 »
Stahnul jsem si script na automaticky zamykani pc kdyz neni v dosahu muj telefon (funkcni pres bluetooth)
tady je ten script:
#!/bin/bash
#
# Written by Pieter de Rijk (pieter@de-rijk.com)
#
# Version 0.1
#
# License GPL 2.0
#
# This script checks using hcitool scan for a bluetooth
# device you have defined in AUTHMAC. If it cannot find
# this device, the computer will be locked using xlock.
#The mac-addres of the bluetoothdevice
AUTHMAC="NO-MAC-DEFINED"
if [ $AUTHMAC == "NO-MAC-DEFINED" ]; then
echo "PLEASE FILL IN THE MAC ADDRES OF YOUR BLUETOOTH DEVICE, IE YOUR PDA/MOBILE"
exit
fi
while [ true == true ];
do
#Check if the bluetooth device of the computer is available, to
#avoid unwanted locks.
LOCAL_DEVICE_AVAILABLE=`hcitool device | grep -c hci`
if [ $LOCAL_DEVICE_AVAILABLE != "0" ]; then
#Scan for the authorised bluetooth device
SEARCH_FOR_DEVICE=`hcitool scan | grep -c $AUTHMAC`
if [ $SEARCH_FOR_DEVICE != "1" ]; then
#It wasn't found, so lock the computer :)
xlock -mode nose -message "Locked, because the authorised bluetooth device is not available!"
fi
else
#Cannot locate the local bluetooth device, so lock the screen.
xlock -mode nose -message "Locked, because the local bluetooth device is not available"
#The authorised user can unlock the computer, after that I scan
#for the local bluetooth device. If it is back I will resume
#the rest of the script.
while [ $LOCAL_DEVICE_AVAILABLE == "0" ];
do
LOCAL_DEVICE_AVAILABLE=`hcitool device | grep -c hci`
done
fi
done
Želví edit: prosím příště do kódu, v citaci je to docela nanic. Jestli se dobre domnivam tak misto PLEASE FILL IN THE MAC ADDRES OF YOUR BLUETOOTH DEVICE, IE YOUR PDA/MOBILE mam vyplnit mac adresu myho founu.
Ale jaksi mi to nefunguje. Spoustim to prikazem ./nazevscriptu
Nevite co delam spatne?
« Poslední změna: 09 Ledna 2009, 01:42:12 od Anna Taliánová »
IP zaznamenána
Acer Aspire 5670 - Ubuntu 10.04
Intel Core2duo 1,8 ghz,2GB ram,Nvidia 260 gtx- ubuntu 10.04,opensuse 11.1 a win 7