📄 events.sh
字号:
#!/bin/bash#! /usr/local/bin/vm shell## This is a demo script for the new event handling interface between# shell scripts and the voice library.## $Id: events.sh,v 1.1.1.1 2004/04/13 19:55:46 andyxem Exp $### Define the function to receive an answer from the voice library#function receive { read -r INPUT <&$VOICE_INPUT; echo "$INPUT"; }## Define the function to send a command to the voice library#function send { echo $1 >&$VOICE_OUTPUT; kill -PIPE $VOICE_PID }## Let's see if the voice library is talking to us#ANSWER=`receive`if [ "$ANSWER" != "HELLO SHELL" ]; then echo "$0: voice library not answering" >&2 exit 1fi## Let's answer the message#send "HELLO VOICE PROGRAM"## Let's see if it worked#ANSWER=`receive`if [ "$ANSWER" != "READY" ]; then echo "$0: initialization failed" >&2 exit 1fi## Set the device to the dialup line#send "DEVICE DIALUP_LINE"## Let's see if it worked#ANSWER=`receive`if [ "$ANSWER" != "READY" ]; then echo "$0: could not set output device" >&2 exit 1fi## Enable events#send "ENABLE EVENTS"## Let's see if it worked#ANSWER=`receive`if [ "$ANSWER" != "READY" ]; then echo "$0: could not enable events" >&2 exit 1fi## Let's wait for one hour#send "WAIT 3600"## Let's see if it worked#ANSWER=`receive`if [ "$ANSWER" != "WAITING" ]; then echo "$0: could not start waiting" >&2 exit 1fi## Let's start an infinite loop#echo "Waiting for voice events..."while /bin/truedo # # Let's wait for events # ANSWER=`receive` # # And print, what we got # echo "$ANSWER" # # Let's exit upon a 0 # if [ "$ANSWER" = "0" ]; then break fidoneecho "Exiting..."## Let's stop waiting#send "STOP"## Let's see if it works#ANSWER=`receive`if [ "$ANSWER" != "READY" ]; then echo "$0: could not stop waiting" >&2 exit 1fi## Let's say goodbye#send "GOODBYE"## Let's see if the voice library got it#ANSWER=`receive`if [ "$ANSWER" != "GOODBYE SHELL" ]; then echo "$0: could not say goodbye to the voice library" >&2 exit 1fiexit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -