У меня была точно такая же проблема, и удаление Timidity решило ее. Буквально, когда пакет был удален apt, я увидел уведомление о том, что у меня есть звуковая карта (, интерпретируемое как изменение громкости ).
1 )используйте либо [ -d...]
, либо test -d...
, но неtest -d [... ]
(то же самое касается-f
)
2)test -f [ $file ]
будет
[
3 )в
if test [ -d "$dir" ]
then
echo "Found directory /tmp/gotcha/" ]
else
mkdir /tmp/gotcha/
fi
вы можете использовать dir
var
if test -d "$dir"
then
echo "Found directory $dir" ]
else
mkdir "$dir"
fi
Мне удалось найти свою (большую )ошибку. Я многое пытался очистить, и в процессе я заметил, что в сценарии sendEmail, который я использовал, отсутствует опция:
-o tls=yes
В итоге скрипт работает полностью и выглядит намного аккуратнее:
#!/bin/bash
##########
## variable key
file=/tmp/gotcha/pic.jpg
dir=/tmp/gotcha
SMTPFROM=xxxxx@xxxxx.com
SMTPTO=xxxxx@xxxxx.com
SMTPSERVER=smtp.googlemail.com:587
SMTPUSER=xxxxx@xxxxx.com
SMTPPASS=xxxxx
SUBJECT="Someone tried to access your computer while you were away."
MESSAGE="Someone tried to access your computer while you were away. Here's a photo!"
##########
## create directory if it doesn't exist
if test -d "$dir"
then
echo "Found directory...";
else
echo "Directory not found..."
sleep 1.5
echo "Creating directory $dir..."
mkdir -p $dir
sleep 1.5
echo "Directory created...";
fi
##########
## ensures directory is clear before beginning script
if test -f "$file"
then
echo "Clearing directory of any past files..."
sudo rm $file;
fi
##########
## takes picture with webcam if incorrect password is entered
## stores picture in created directory
ts=`date +%s`
ffmpeg -f video4linux2 -s vga -i /dev/video0 -vframes 1 $file
#exit 0 ## NOTE - must exit with status 0
##########
## send $file in email
sudo sendemail -f $SMTPFROM -t $SMTPTO -o tls=yes -a $file -u $SUBJECT -m $MESSAGE -s $SMTPSERVER -xu $SMTPUSER -xp $SMTPPASS
##########
Не обращайте внимания на лишние хэши, это просто мой способ организации. Я уверен, что многое еще можно было бы сделать лучше, и много ненужного, но это работает! Спасибо за ваш вклад!