?? fax
字號:
#!/bin/sh # # fax - script to make, send, receive, view or print a fax# Copyright Ed Casas 1993, 1994, 1995# # --- Start of user configuration section --- # # Note: do not put spaces before or after the equal (=) signs.## The name of the efax and efix executables, including full path# if necessary.EFAX=efaxEFIX=efix# The device to which the fax modem is connected (e.g. ttya for# /dev/ttya). Use a dial-out (cua) device if sharing modem with# dial-out programs.DEV=cua1# The type of fax modem commands to use. Un-comment one of the# following 3 lines depending on your modem.# CLASS=1CLASS=2# CLASS=2.0 # doesn't work yet# Your fax number in international format, 20 characters maximum.# Use only digits, spaces, and the "+" character.FROM="+1 800 555 2368"# Your name as it should appear on the page header.NAME="Put Your Name Here"# The preferred page size for creating and printing faxes.# Predefined values are "letter", "legal", "a4" and "A4".PAGE=letter# The type of printer. Use 'pcl' for HP-PCL or 'ps' for# Postscript. See definition of PRINT (below) for other printers# and print options.PRTYPE=pcl # HP-PCL (e.g. HP LaserJet) # PRTYPE=ps # Postscript (e.g. Apple LaserWriter)# The command to print graphics (the fax image) from standard# input. Typically this is "lpr" or "lp".PRCMD="lpr"# The command to view a Portable Gray Map (PGM) image from the# standard input. Typically this is "xloadimage stdin" or "xv".VIEWCMD="xloadimage stdin"# VIEWCMD="pnmtoxwd | xwud" # alternative# VIEWCMD="xv -" # alternative# The name of the Ghostscript executable including full path if# necessary. Required only if sending Postscript files.GS=gs# Dial string prefix and suffix such as T for tone dialing, P for# pulse dialing, 9 to get an external line, commas for delays or# W to wait for dial tone. See definition of TELCVT (below) if# you have more complex requirements.DIALPREFIX="T"DIALSUFFIX=""# The name(s) of lock file(s) according to your system's# conventions. Protect with single quotes for delayed evaluation.# Add a leading '#' to the file name for HDB (ASCII) format.LOCK='-x /usr/spool/uucp/LCK..$DEV' # "normal" systems# LOCK='' # no lock file# LOCK='-x /usr/spool/locks/LK.047.040.011' # SysV style names# LOCK='-x #/usr/spool/uucp/LCK..$DEV' # HDB format (ASCII pid)# LOCK='-x /usr/spool/uucp/LCK/LCK..$DEV' # NeXT# Uncomment one of the following lines to force xon/xoff flow# control only if you have one of the modems listed.# FCINIT="-i\Q4" # AT&T modems (Dataport, Paradyne)# FCINIT="-i&H2&R1&I2" # USR modems (Courier, Sportster)# ****************************************************************# The remaining options probably won't need to be changed.# ****************************************************************# The fax script file name. "$0" should almost always work.FAX=$0# Message verbosity. Use "chewmainr" for verbose logging when# analyzing or reporting problems.VERB="ewin" # default: errors, warnings, info, negotiation# VERB="chewmainr" # everything# A unique name for logs and received files. `date +%m%d%H%M%S`# works on most systems.TSTAMP=`date +%m%d%H%M%S`# TSTAMP=`date | tr ' ' '-'` # alternative - readable date/time# TSTAMP=$$ # alternative - process number# Shell command to convert names to phone numbers when sending# faxes. At execution $1 will be the name and $f the file name# to search. The example below uses a directory file where alias# lines start with the keyword "fax" followed by the alias in# parentheses and a colon. The remainder of the line is taken to# be the phone number. Other lines are ignored. For example, if# one of the files in DIRFILES (defined below) contained the line# "fax(kpmg): 691-3031", you could use the command "fax send kpmg# invoice.24".LOOKUP='eval sed -n -e "/^fax($1):/{" -e "s/^[^:]*://p" -eq -e"}" $f'# List of telephone directory file(s) to be searched. The# default is the file .faxdir in the user's home directory.DIRFILES="${HOME:-.}/.faxdir"# Shell command to modify phone numbers. This can be used to# access long distance or alternate carriers, add passwords or# accounting digits, etc. In the examples below this is used to# convert numbers beginning with '+'; the first substitution# handles same-country calls and the second handles international# calls.TELCVT='sed -e s/+1/1/ -e s/+/011/' # North America# TELCVT='sed -e s/+44/0/ -e s/+/010/' # UK# TELCVT='sed -e s/+852// -e s/+/001/ # Hong Kong# TELCVT='sed -e s/+33// -e s/+/19W/' # France (?)# TELCVT='sed -e s/+1/10288/' # use AT&T# TELCVT='sed -e s/+/T82W1682W9W/' # get out of PBX# efix options for text-to-fax conversion. -d0.5,0 sets 1/2 inch# left margin. -l66 gives 66 lines of text per page.TEXTMARGIN="-d0.5,0 -l66"# Scaling of the built-in 8x16 built-in font when generating text# pages. Vertical scaling by 2 (or 1 at low resolution) gives a# 12-point font that fits 66 lines on 11 inch paper.TEXTSIZEhigh="-s2.0x2.0"TEXTSIZElow="-s2.0x1.0"# The font files and scaling to use for text-to-fax conversion.# Comment these out to use the built-in font.# FONTDIR=`dirname $FAX` # use appropriate directory# TEXTSIZEhigh="-f $FONTDIR/efaxfont.h -s 1.0x1.0"# TEXTSIZElow=" -f $FONTDIR/efaxfont.l -s 1.0x1.0"# Dimensions of page sizes. Add any others you like.PAGE_letter="8.465x11in" # fax width x letter lengthPAGE_legal="8.465x14in" # fax width x legal length (?)PAGE_A4="21x29.7cm" # ISO A4 (?)PAGE_a4="$PAGE_A4"# When the print and view commands below are executed, the value# of $RES will have one of two resolution-dependent values# (e.g. VIEWhigh or VIEWlow). $PAGEDIM will have one of the# above PAGE_x values. Put single quotes around the PRINT and# VIEW commands and use $f for the input file name.# Command and options to convert a fax file to printable format.# Change the scaling and displacement options if your printer# can't print received faxes at full scale or at the default# origin. For printers other than Postscript or PCL select an# appropriate PRTYPE above (e.g. pbm or ps) and insert the# appropriate filter (e.g. pbmtoepson or gs).PRINT='$EFIX -ve -p$PAGEDIM $RES -o$PRTYPE $f'PRINThigh="-s1.471x1.515 -r300 -d0,0.125" # convert 204x196 (fax) to 300 dpiPRINTlow=" -s1.471x3.125 -r300 -d0,0.125" # and shift down 1/8"# PRINT='$EFIX -ve -p$PAGEDIM $RES -o$PRTYPE $f | pbmtoepson'# PRINThigh="-s0.29x0.36 -r72" # convert 204x196 (fax) to 60x72 dpi# PRINTlow=" -s0.29x0.72 -r72"# Command to convert a fax file to PGM format for previewing (pgm# conversion decimates by 4).VIEW='$EFIX -ve -p$PAGEDIM $RES -opgm $f'VIEWhigh="-s1x1" # faster, whole-page viewVIEWlow=" -s1x2"#VIEWhigh="-s1.5x1.5 -r306x294" # slower, readable size#VIEWlow=" -s1.5x3.0 -r306x294"# Commands to set up modem. "-iZ -i&FE0Q0V1X4&D2S7=120 -i&C0"# sets up almost all modems. See the efax(1) man page for# details.INIT="-iZ -i&FE0Q0V1X4&D2S7=120 -i&C0"# Command(s) to reset modem when efax finishes. "-zZ" works in# almost all cases.RESET="-zZ"# RESET="-zZ -z&F+FCLASS=0" # for modems that stay in fax mode after reset# Speaker mode(M) and loudness(L). Mn sets speaker mode where n# means: 0:never, 1:until carrier, 2:always, 3:on receive only.SPKR="-iM1L0"# Initialization commands for different command sets. For Class# 1: "-i+FCLASS=1 -o1". For Class 2: "-i+FCLASS=2 -i+FCR=1".# Almost all Class 2 modems also need the -or option to reverse# the bit order on receive.CLASS1INIT="-i+FCLASS=1 -o1" # Class 1CLASS2INIT="-i+FCLASS=2 -i+FCR=1 -or" # Class 2CLASS20INIT="-i+FCLASS=2.0 -i+FCR=1 -o0" # Class 2.0 (doesn't work)# The modem's hardware/software capabilities for sending faxes# excluding the "vr" (first) field. "3,0,0,0,0,0,0" should# almost always work. The first digit can be 5 for a 14,400 bps# fax modem. See the efax(1) man page for a description of the# fields.TXCAP="3,0,0,0,0,0,0"# Capabilities for receiving faxes. Usually the same as TXCAP.# If your modem only receives at 4800 bps use "1,0,0,0,0,0,0".RXCAP="$TXCAP"# Additional options required only for transmit or only for# receive. None normally required.RXINIT=""TXINIT=""# Command to make a date for the page header. Protect with single# quotes. 'date "+%y/%m/%d %H:%M"' works on most systems.HDRDATE='date \"+%y/%m/%d %H:%M\"' # YY/MM/DD HH:MM (24hour)# HDRDATE='date' # longer, more readable# Page header format. You may use $DATE, $NAME, $FROM, $TO, and# "%d/%d" (for page number and count). Protect with single# quotes. Example: '$DATE $NAME ($FROM) --> $TO p. %d/%d'.HDR='$DATE $NAME ($FROM) --> $TO p. %d/%d'# BUSYRETRIES is a list of delays (in seconds) between attempts# to redial busy numbers. Comment out if you don't want to retry# busy numbers.## Note: If you're using the Qfax 1.0 suite and calling Qrun from a# crontab entry, you probably want to comment out this entry so# that the spool can handle its own retries.#BUSYRETRIES="30 60 120 300 60 600 60 60 1200 60 60"# A list of signals to be ignored by the script so efax can# terminate gracefully. HUP (1), INT (2), QUIT (3), and TERM# (15) are probably enough.SIGNALS="1 2 3 15"# Command to run another program (efax) at a higher-than-normal# scheduling priority. This command isn't used if it fails# (e.g. because the current user isn't privileged). Comment this# out if it causes problems.NICE="nice -n -10"# Standard versions of commands that are often aliased.# Note: If you use a colour ls, you should disable this feature# with the "--colour=no" switch. (Added for Qfax 1.0)RM="/bin/rm"LS="/bin/ls"# ****************************************************************# The remaining configuration options apply only to the `fax# answer' command. You can ignore these if you will only be# running efax manually. See "USING INIT TO RUN EFAX" in the# efax man page for more information.# ****************************************************************# device or file where fatal error messages should be writtenCONSOLE=/dev/console# The directory to store incoming faxes and log files. This directory# should already exist and be writable by the user(s) of this script.FAXINDIR=/usr/spool/fax/recvq# The directory to store outgoing faxes waiting to be sent.FAXOUTDIR=/usr/spool/fax/sendq# The directory to store log files in (except for automatic reception).FAXLOGDIR=/usr/spool/fax/log# The strftime(3) pattern that generates the file name for received files.# At 10:45:36 on February 25, for example, "%m%d%H%M%S" would produce# 0225104536, "%j-%H%M" would produce 056-1045, and %d%b%H%M 25Feb1045.ANSFNAME="%d%b%H%M%S"# umask for received files. Use 022 to allow anyone to retrieve faxes.UMASK=022# The command to execute when a fax is received. Normally this# sends someone e-mail or prints the faxes. Protect with single# quotes. The variable FILES will contain the names of the# received files and RESSWITCH will be -l if the file was# received at low resolution. Comment this out to do nothing.NOTIFY='mail -s "received fax files $FILES on `date`" $FAXMGR <$logfile'# NOTIFY='lpr $logfile ; $FAX print $RESSWITCH $FILES'# The user to be sent mail when a fax is received.FAXMGR=FaxMaster# The number of rings to wait before answering.ANSRINGS=1# Initialization options to enable fax/data adaptive answer (AA).# You must also define GETTY (below) to enable AA. NOTES: (1) AA# does not work properly on some (2400/9600) modems unless the# modem initialization is done at 2400 bps (not possible with# efax). (2) I have been unable to make AA work with my Zoom# modem in Class 1. Note that USR modems do not support modem# adaptive answer (+FAE=) in Class 1.# DATAINIT="" # Class 1 no adaptive answer# DATAINIT="-i+FAE=1" # Class 1 modem adaptive answer# DATAINIT="-i+FCLASS=0 -oa" # Class 1 software adaptive answer# DATAINIT="-i+FAA=0" # Class 2 no adaptive answer# DATAINIT="-i+FAA=1" # Class 2 modem adaptive answer# DATAINIT="-i+FAA=0 -i+FCLASS=0 -oa" # Class 2 software adaptive answer# Argument passed to exec(2) of "/bin/sh -c" for incoming data calls. This# command will usually exec getty(8). Up to 6 %d arguments are replaced by# the baud rate following the CONNECT response from the modem (or 300 if# none). Use 'nice' if required to reduce any special priority set by# NICE. Comment out if you don't want to handle data calls.# GETTY="exec /sbin/getty -h $DEV %d" # for getty_ps (Linux)## --- End of user configuration section ---## --- set any variables given on command linewhile : ; do case $# in 0) break ;; esac case "$1" in [A-Z]*=*) eval $1 ; shift ;; *) break ;; esacdone# -------- initialize ERR=0logfile=$FAXLOGDIR/${TSTAMP}.log$NICE true 2>/dev/null ; case $? in 0) ;; *) NICE="" ;; esaceval LOCK=\"$LOCK\" # resolve dependency on DEVeval DEVN=`echo $DEV|sed -e s./._.` # make device name w/o directorieseval PAGEDIM=\"\$PAGE_$PAGE\" # resolve dependency on PAGEcase "$CLASS" in 2.0) CLASSINIT="$CLASS20INIT" ;; # Class 2.0 2) CLASSINIT="$CLASS2INIT" ;; # Class 2 1) CLASSINIT="$CLASS1INIT" ;; # Class 1 *) echo "bad CLASS=$CLASS" ; exit 2 ;;esac# --- check for a command and optional resolution flagres=highVR=1case $# in 0) cmd=receive ;; 1) cmd=$1 ; shift ;; *) cmd=$1 ; shift ; case $1 in -l) RESSWITCH=-l ; res=low ; VR=0 ; shift ;; esac ;; esac# -------- do the appropriate commandwhile : ; do # so we can use `break' to get to the end of the scriptcase $cmd in # fax answer : clean up logs and exec efax. normally run by init(8). answer) if cd $FAXINDIR ; then : else echo "Error: $FAX cannot cd to $FAXINDIR" >>$CONSOLE ; sleep 30 break fi while [ -f ${DEVN}.stop ] ; do sleep 15 ; done umask $UMASK for f in ${DEVN}.[0-9]* # clean up old log files do if [ ! -r $f ] ; then continue ; fi if grep "done, returning [145]" $f >/dev/null ; then true # ignore `signal,' `locked,' and `no modem' exits else FILES=`sed -n -e '/received/s/[^>]*>\([^(]*\).*/\1/p' $f` FILES=`echo $FILES` logfile=$f grep "session\ *98lpi" $logfile >/dev/null case $? in 0) RESSWITCH=-l ;; esac eval $NOTIFY echo >>${DEVN}.log cat $f >>${DEVN}.log fi $RM -f $f done exec $NICE $EFAX -d/dev/$DEV -v"$VERB" $LOCK $INIT $SPKR \ $CLASSINIT $FCINIT $RXINIT \ -c "$VR,$RXCAP" -l "$FROM" $RESET \ $DATAINIT -g "$GETTY" \ -iS0=$ANSRINGS -w -s -r "$ANSFNAME" \ > ${DEVN}.$$ 2>&1 echo ERROR: $FAX answer exec failed >>$CONSOLE ; sleep 30 break ;;# fax wait : runs fax answer (emulates init(8) but PPID != 0) wait) while : ; do echo running $FAX answer $FAX answer done break ;;# fax queue : list received fax files q*) cd $FAXINDIR ; case $? in 0) ;; *) echo "cannot cd to $FAXINDIR" ; break ;; esac if $LS [0-9]*.[0-9][0-9][0-9] >/dev/null 2>/dev/null then echo
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -