⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dtmf_alpha.sh

📁 VoiFax is a program that manage voice/data/fax modem in the same manner of vgetty and mgetty.VoiFax
💻 SH
字号:
#!/bin/bash#!/usr/bin/vm shell # Robert J鰎dens <rjo@gmx.de>## This is the dtmf script. It is called by vgetty when a dtmf code was send by# the user.## $1 - received DTMF code## $2 - name of the recorded voice file or if "-cons_mode", switches on console# mode so you can enter the dtmf-codes on your console and will hear all sound# going to your soundcard! (you also have to toogle the magic line at the# beginning!)#if [ "1$2" = "1-cons_mode" ]; then	CONS_MODE="yes"else	CONS_MODE="no"fi#BASENAME=`basename $0`DTMF="$1"ALREADY_REC="$2"# Some dir'sVOICE_DIR=/var/spool/voiceMSG_DIR=$VOICE_DIR/messagesINC_DIR=$VOICE_DIR/incoming# Some files (scripts may have to be written)CODE=`cat $VOICE_DIR/.code`FLAG=$VOICE_DIR/.flagTIMESTAMP=$VOICE_DIR/.timestampCONNECT_SCRIPT=$VOICE_DIR/ppp.shFAX_ACTIVATE_SCRIPT=$VOICE_DIR/fax_activate.sh# Sound-FilesGET_CODE=$MSG_DIR/get-code.rmdINCORRECT=$MSG_DIR/incorrect.rmdGOODBYE=$MSG_DIR/goodbye.rmdNO_NEW_MESSAGES=$MSG_DIR/no_new_messages.rmdGIMME_COMM=$MSG_DIR/gimme_comm.rmdOKAY_DRIN=$MSG_DIR/okay_drin.rmdBYE=$MSG_DIR/bye.rmd# The TTY's where to toogle the Scroll-LEDLEDTTY=/dev/tty[1-8]# Tries CodeMAXTRIES=3# Timeout beetween two equal numbers to be recognized as two single. Under# TIMEOUT: increment (see dtmf_alph)TIMEOUT=2# Type of your ModemMODEM_TYPE=Rockwell# CompressionCOMPRESSION=4# Sample Rate neededSPEED=7200### BEGIN FUNCTIONS# Define the function to check for an answer and if it is not the desired it# will quit!answer () {    ANSWER=`receive`    if [ "$ANSWER" != "$1" ]; then	logger -t "${BASENAME}[$$]" "Got '$ANSWER', expected '$1'. Harakiri"       	kill -KILL $$    fi}# Define the function to receive an answer from the voice libraryreceive () {  if [ $CONS_MODE = "no" ]; then     read -r INPUT <&$VOICE_INPUT  else     read -r -p "receive: " INPUT  fi  echo "$INPUT"}# Define the function to send a command to the voice librarysend () {  if [ $CONS_MODE = "no" ]; then     echo $1 >&$VOICE_OUTPUT     kill -PIPE $VOICE_PID  else     echo "send: $1"  fi}# Define the function send a beepbeep () {  if [ $CONS_MODE = "no" ]; then     send "BEEP $1 $2"     answer "BEEPING"     answer "READY"  else     echo "beep: $1 $2"  fi}# Define the function to play a fileplay () {   if [ $CONS_MODE = "no" ]; then     send "PLAY $1"     answer "PLAYING"     answer "READY"   else     rmdtopvf $1 | pvfspeed -s 8000 | pvftobasic > /dev/audio   fi     logger -t "${BASENAME}[$$]" "Played $1"}# Define the function to play the new messagesmessages () {     if [ ! -f $TIMESTAMP ]; then          MSGS=`find $INC_DIR/ -type f -name 'v*.rmd' -print`     else          MSGS=`find $INC_DIR/ -type f -name 'v*.rmd' -newer $TIMESTAMP -print`          if [ -z "$MSGS" ]; then               BASENAME=`basename $TIMESTAMP`               NEWSTAMP=`find $VOICE_DIR -name $BASENAME -cmin -10 -print`               if [ "$NEWSTAMP" = "$TIMESTAMP" ]; then                    MSGS=`find $INC_DIR -type f -name 'v*.rmd' -print`               fi          fi     fi     touch $TIMESTAMP-n     if [ -x $VOICE_DIR/speakdate.sh ]; then          TIME=yes     else          TIME=no     fi     TMPDIR=${TMPDIR-/tmp}/dtmf.$$     mkdir -m 0700 $TMPDIR || exit 1     trap "rm -rf $TMPDIR" 0 1 2 3 7 13 15     TMP=${TMPDIR}/time.rmd.$$     LOCK=${TMPDIR}/time-lock.$$     for i in $MSGS     do          if [ $TIME = yes ]; then               (touch $LOCK ;\               $VOICE_DIR/speakdate.sh $i $SPEED $MODEM_TYPE $COMPRESSION >$TMP ;\               rm -f $LOCK) &          fi          beep 1320 100          play $i          beep 1320 100          if [ $TIME = yes ]; then               while [ -f $LOCK ]               do                    sleep 1               done               play $TMP               rm -f $TMP          fi     done     if [ -z "$MSGS" ]; then          play "$NO_NEW_MESSAGES"     fi     beep 1320 1000     rm -f $FLAG $TIMESTAMP     mv $TIMESTAMP-n $TIMESTAMP#     for tty in $LEDTTY; do#         setleds -scroll < $tty#     done}# Define the function to read one dtmf code string terminated by #getcode () {  if [ $CONS_MODE = "no" ]; then     RECEIVED=""     send "ENABLE EVENTS"     answer "READY"     send "WAIT 30"     answer "WAITING"     ANSWER=""     while [ "$ANSWER" != "READY" ]     do          ANSWER=`receive`          if [ "$ANSWER" = "RECEIVED_DTMF" ]; then               ANSWER=`receive`               if [ "$ANSWER" = "*" ]; then                    RECEIVED=""               else                    case $ANSWER in                    "#")                         send "STOP"                    ;;                    0|1|2|3|4|5|6|7|8|9)                         RECEIVED=$RECEIVED$ANSWER                    ;;                    *)                         logger -t "${BASENAME}[$$]" "Ignoring DTMF $ANSWER"                    ;;                    esac               fi          else               if [ "$ANSWER" = "SILENCE_DETECTED" ]; then                    send "STOP"               else                    if [ "$ANSWER" != "READY" ]; then                         logger -t "${BASENAME}[$$]" "Ignoring $ANSWER"                    fi               fi          fi     done     send "DISABLE EVENTS"     answer "READY"  else     read -r -p "Code: " RECEIVED  fi     echo "$RECEIVED"     }# Get a SMS-like String from DTMF's. The Code-Table is not standard!!dtmf_alph () {    TAB_0=(0 + - '#' '*' , '.' : ';' '?' '!' '|' @ / '\\' '$' % 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -