All pastes #418984 Raw Edit

mrebola

public shellscript v1 · immutable
#418984 ·published 2007-03-31 23:40 UTC
rendered paste body
Hola pues espero alguien pueda ver esto y me diga la causa de lo que pasa conmigo ...ya modifique el script quedando haci:#!/bin/sh####################################################### aimtooth: detector de presencia bluetooth          ##----------------------------------------------------## Javier Pérez <javier@javierperez.eu>               ## http://javierperez.eu                              ##                                                    ## v0.1a Madrid 2007                                  ########################################################## CONFIGURACION DE USUARIO #### Nombre del teléfono movilNAME="mrebola"# ID del telefono (ver hcitools scan)ID="00:16:20:F4:07:B1"# Se ejecutarán los siguientes comandos en los eventos conectado y desconectadoON_CONNECT="sudo -u mrebola gnome-screensaver-command --deactivate"ON_DISCONNECT="sudo -u mrebola gnome-screensaver-command --lock"# Si la calidad de conexión es inferior a este valor, se entenderá#	que el dispositivo se alejó del PCQ_CONNECT=230Q_DISCONNECT=205Q_RETRIES=3### CARGA CONFIGURACION DE ~/.aimtooth[ -f ~/.aimtooth ] && . ~/.aimtooth && echo "CARGADO FICHERO DE CONFIGURACION LOCAL"### VARIABLES SISTEMA #### indica si el movil está conectadoCONNECTED=1# si 1 entonces se muestran mensajes de depuraciónDEBUG=1# intervalo de tiempo (segundos) en el que se comprueba la presencia del teléfonoSLEEPTIME=3# 1 si el PC está conectado al teléfonoCC=0# media de calidad de conexiónQ_MEDIA=0Q_LAST=-1Q_COUNTER=0### BUCLE ###while sleep $SLEEPTIME; do	# obtiene el nombre del dispositivo $ID	SCAN=`hcitool name $ID 2>/dev/null`	[ $? -ne 0 ] && echo "ERROR: No se pudo obtener el nombre del dispositivo"	# si el ID dado tiene el nombre de nuestro teléfono...	if [ "$SCAN" = "$NAME" ]; then		# conecta con el telefono		if [ $CC -eq 0 ]; then			`hcitool cc $ID 2>/dev/null`			if [ $? -eq 0 ]; then				CC=1				[ $DEBUG -eq 1 ] && echo "AIMTOOTH: conectado al dispositivo"			else				echo "ERROR: No se pudo conectar con el dispositivo!"			fi		fi		# obtiene calidad de señal		LQ=`hcitool lq $ID | cut -d" " -f3 2>/dev/null`		# echo "[$LQ]"		if [ -z "$LQ" ]; then			# problemas con la conexión... desconectado!			[ $DEBUG -eq 1 ] && echo "AIMTOOTH: problemas de conexion"			LQ=0			Q_LAST=0			Q_MEDIA=0			Q_COUNTER=$Q_RETRIES		else			# calcula media			if [ $Q_LAST -gt -1 ]; then				#echo "calculando media..."				Q_MEDIA=`expr $Q_LAST + $LQ`				Q_MEDIA=`expr $Q_MEDIA / 2`				#echo "fin calculando media"			else				Q_MEDIA=$LQ			fi			Q_LAST=$LQ		fi	else		# el dispositivo no está		[ $DEBUG -eq 1 ] && echo "AIMTOOTH: dispositivo desconectado"		LQ=0		CC=0		Q_MEDIA=0		Q_LAST=0		Q_COUNTER=$Q_RETRIES	fi	if [ $Q_MEDIA -ge $Q_CONNECT -a $CONNECTED -eq 0 ]; then		# echo "expr $Q_COUNTER + 1"		Q_COUNTER=`expr $Q_COUNTER + 1`	elif [ $Q_MEDIA -le $Q_DISCONNECT -a $CONNECTED -eq 1 ]; then		# echo "expr $Q_COUNTER + 1"		Q_COUNTER=`expr $Q_COUNTER + 1`	else		# echo "Q_COUNTER=0"		Q_COUNTER=0	fi	# info datos obtenidos	[ $DEBUG -eq 1 ] && echo "AIMTOOTH (`date +'%X'`): CONNECT=$CONNECTED / Q=$LQ / QLAST=$Q_LAST / QM=$Q_MEDIA / QCOUNTER=$Q_COUNTER"		# si el dispositivo sobrepasa el umbral Q_CONNECT, y el salvapantallas está	#	activado...	if [ $Q_COUNTER -ge $Q_RETRIES ]; then		if [ $Q_MEDIA -ge $Q_CONNECT -a $CONNECTED -eq 0 ]; then			[ $DEBUG -eq 1 ] && echo "AIMTOOTH: presencia detectada!"			CONNECTED=1			Q_COUNTER=0			$ON_CONNECT			if [ ! -z "$ON_CONNECT2" ]; then				$ON_CONNECT2			fi		# si el dispositivo está por debajo de Q_DISCONNECT, y el sistema se encuentra		#	en modo CONECTADO...		elif [ $Q_MEDIA -le $Q_DISCONNECT -a $CONNECTED -eq 1 ]; then			[ $DEBUG -eq 1 ] && echo "AIMTOOTH: se detectó ausencia!"			CONNECTED=0			Q_COUNTER=0			$ON_DISCONNECT			if [ ! -z "$ON_DISCONNECT2" ]; then				$ON_DISCONNECT2			fi		fi	fidone______________________________________________________y de ahi lo unico que hago es correrlo dura unos 3 segundos sin bloquearse la pantalla y depronto se bloquea.lo que me muestra la shell es esto.root@mrebola-desktop:/home/mrebola/more/aimtooth# sudo ./aimtoothAIMTOOTH: conectado al dispositivoNot connected.AIMTOOTH: problemas de conexionAIMTOOTH (17:20:36): CONNECT=1 / Q=0 / QLAST=0 / QM=0 / QCOUNTER=4AIMTOOTH: se detectó ausencia!Not connected.AIMTOOTH: problemas de conexionAIMTOOTH (17:20:40): CONNECT=0 / Q=0 / QLAST=0 / QM=0 / QCOUNTER=0Not connected.AIMTOOTH: problemas de conexionAIMTOOTH (17:20:43): CONNECT=0 / Q=0 / QLAST=0 / QM=0 / QCOUNTER=0Not connected.AIMTOOTH: problemas de conexionAIMTOOTH (17:20:47): CONNECT=0 / Q=0 / QLAST=0 / QM=0 / QCOUNTER=0el scanning de mi bluetooth ahi les vamrebola@mrebola-desktop:~$ hcitool scanScanning ...        00:16:20:F4:07:B1       mrebolamrebola@mrebola-desktop:~$ como veran si funciona el bluetooth no se que esta mal :(espero me puedan ayudar :D salu2