이것은 꽤 복잡한 솔루션 일지 모르지만, 내가 원하는 것을 수행합니다. log.txt에 변화를
#ensure that the call is made only once, preventing an infinite loop
if [ $SHLVL == 1 ]
then
script -afq ~/custom/log.txt #log everything that happens in the shell
fi
#call my script only once by checking for another instance of it
if [[ ! $(pidof -x script.sh) ]]
then
~/custom/script.sh&
fi
내 script.sh 파일 검사 및 경고음을 (당신이 그것을 다운로드해야합니다) 그렇게되면 재생 : 내 .bashrc에 파일에서
, 나는 다음과 같은 추가 : 그 때마다 뭔가 입력을 포함하여 쉘의 변화 때문에
#!/bin/bash
$(stat -c %y ~/custom/log.txt > ~/custom/update.txt)
while :
do
now=$(stat -c %y ~/custom/log.txt)
update=$(cat ~/custom/update.txt)
if [ "$now" != "$update" ]
then
$(stat -c %y ~/custom/log.txt > ~/custom/update.txt)
$(play -q ~/custom/beep.ogg vol 0.1) #props to franklin
fi
done
이 그것을 만들 것입니다, script.sh는 play
를 실행합니다. 이제 터미널을 볼 필요없이 WEBrick 서버에 요청이있을 때마다 알게되었습니다.
벨 문자가 작동합니까? 'echo -e "\ a"' – August
시도해보십시오. http://unix.stackexchange.com/questions/8607/how-can-i-play-a-sound-when-script-execution-is-ready 기본적으로'; '구분 기호를 사용하여 BASH에게 소리를 내도록 지시합니다. 첫 번째 명령이 완료되면 파일. – franklin
빈 줄이 생깁니다. –