Debian Codegraph @

ex24.sh

raw symbols SCIP
1 #!/bin/bash
2 # Faxing (must have 'efax' package installed).
3
4 EXPECTED_ARGS=2
5 E_BADARGS=85
6 MODEM_PORT="/dev/ttyS2" # May be different on your machine.
7 # ^^^^^ PCMCIA modem card default port.
8
9 if [ $# -ne $EXPECTED_ARGS ]
10 # Check for proper number of command-line args.
11 then
12 echo "Usage: `basename $0` phone# text-file"
13 exit $E_BADARGS
14 fi
15
16
17 if [ ! -f "$2" ]
18 then
19 echo "File $2 is not a text file."
20 # File is not a regular file, or does not exist.
21 exit $E_BADARGS
22 fi
23
24
25 fax make $2 # Create fax-formatted files from text files.
26
27 for file in $(ls $2.0*) # Concatenate the converted files.
28 # Uses wild card (filename "globbing")
29 #+ in variable list.
30 do
31 fil="$fil $file"
32 done
33
34 efax -d "$MODEM_PORT" -t "T$1" $fil # Finally, do the work.
35 # Trying adding -o1 if above line fails.
36
37
38 # As S.C. points out, the for-loop can be eliminated with
39 # efax -d /dev/ttyS2 -o1 -t "T$1" $2.0*
40 #+ but it's not quite as instructive [grin].
41
42 exit $? # Also, efax sends diagnostic messages to stdout.