LDP/LDP/guide/docbook/abs-guide/ex24.sh

43 lines
1.1 KiB
Bash
Raw Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2006-06-22 14:28:13 +00:00
# Faxing (must have 'efax' package installed).
2001-07-10 14:25:50 +00:00
2001-09-04 13:27:31 +00:00
EXPECTED_ARGS=2
2008-11-23 22:43:47 +00:00
E_BADARGS=85
2007-04-26 21:13:49 +00:00
MODEM_PORT="/dev/ttyS2" # May be different on your machine.
# ^^^^^ PCMCIA modem card default port.
2001-07-10 14:25:50 +00:00
2001-09-04 13:27:31 +00:00
if [ $# -ne $EXPECTED_ARGS ]
2008-11-23 22:43:47 +00:00
# Check for proper number of command-line args.
2001-07-10 14:25:50 +00:00
then
echo "Usage: `basename $0` phone# text-file"
exit $E_BADARGS
fi
if [ ! -f "$2" ]
then
2006-06-22 14:28:13 +00:00
echo "File $2 is not a text file."
# File is not a regular file, or does not exist.
2001-07-10 14:25:50 +00:00
exit $E_BADARGS
fi
2007-04-26 21:13:49 +00:00
fax make $2 # Create fax-formatted files from text files.
2001-07-10 14:25:50 +00:00
2006-06-22 14:28:13 +00:00
for file in $(ls $2.0*) # Concatenate the converted files.
# Uses wild card (filename "globbing")
#+ in variable list.
2001-07-10 14:25:50 +00:00
do
fil="$fil $file"
done
2007-04-26 21:13:49 +00:00
efax -d "$MODEM_PORT" -t "T$1" $fil # Finally, do the work.
# Trying adding -o1 if above line fails.
2001-07-10 14:25:50 +00:00
2006-06-22 14:28:13 +00:00
# As S.C. points out, the for-loop can be eliminated with
2007-04-26 21:13:49 +00:00
# efax -d /dev/ttyS2 -o1 -t "T$1" $2.0*
2006-06-22 14:28:13 +00:00
#+ but it's not quite as instructive [grin].
2001-07-10 14:25:50 +00:00
2007-04-26 21:13:49 +00:00
exit $? # Also, efax sends diagnostic messages to stdout.