Red Hat Linux Unleashed rhl59.htm
Using HylaFAX, sendfax, and mgetty
This chapter deals with a fax application for Linux: HylaFAX. Though there are other fax facilities for UNIX systems, such as netfax, in this chapter, I concentrate on HylaFAX because it may be the most comprehensive. You also have access to the C++ source code to make any necessary modifications to the application to adapt it to your PC.
HylaFAX was invented by Sam Leffler. You can send thanks and an "Atta boy" to him via e-mail at sam@sgi.com. HylaFAX is indeed a great piece of work.
HylaFAX is a system for sending and receiving fax documents. Some of the notable features of HylaFAX include the following:
The Display PostScript interpreter, Ghostscript, is supplied in binary form for Silicon
Graphics machines. There is information on obtaining and setting up Ghostscript (see Chapter 25, "Ghostscript").
HylaFAX can be obtained via public FTP on the Internet. It is also available on a number of public domain and shareware-style CD-ROMs. The master distribution site for HylaFAX is the host ftp.sgi.com. (See the /sgi/fax/binary directory at that site.)
HylaFax is essentially the same program as FlexFAX, but with a new name and many more
features.
All the HylaFAX documentation is online on the World Wide Web (WWW). This documentation describes how to unpack and install the source distribution images. The HylaFAX home page at sgi.com is the place to go for all the HylaFAX documentation.
The HylaFAX source code is available for public FTP on ftp.sgi.com as /sgi/fax/source HylaFAX-v3.0.pl0-tar.gz.
You can get more information about HylaFAX from the WWW by accessing the Web page http://www.vix.com/hylaFAX. Check out
the FAQs at this site for the most up-to-date information.
HylaFAX comes with detailed information on specific modems and configuration instructions in a file called MODEMS. Read this file carefully to see whether your modem is listed. If it is, you should have no problems with HylaFAX. If you cannot find your exact modem, choose the one that best fits the description you have. Chances are that a close enough setting will work fine.
Most of the modems on the list are either Class 1 or 2, and both types are supported by
HylaFAX. Do not confuse the fax Group I, II, or III standards with Class 1 or 2. The
groups discuss how faxes are encoded, and classes explain how you "talk" to a
modem.
First, unzip and untar the source files from the distribution in a local directory. After you get the source file for HylaFAX, the first installation steps are to configure your system and then do a make install command.
The source code is in a compressed tar file. To extract the software
Listing 59.1. The output from the configure command.
Listing 59.2. Sample configuration for HylaFAX.
You are bound to run into difficulties while installing HylaFAX. Despite my assertions in the last section about two simple steps to complete the installation, you still have the potential of running into problems. Here is a brief list of problems and their solutions. The list is by no means complete, nor is it guaranteed the examples will apply to you, but at least it will give you an idea of what could be wrong.
The faxd daemon is the main processing agent of the HylaFAX package. You need one faxd process and FIFO for each fax modem on your system. faxd listens to its own FIFO for all its command directives. When you start faxd, you can use the following options:
There is no way to abort an incoming fax. Just sit back and wait until it's over.
The faxd.recv daemon is the program that implements the server side of the fax job
submission protocol. It also implements extensions to this protocol to support job removal
and the return of status information. faxd.recv is normally invoked by inetd with a line
in the following form:
To send a fax, you will use the sendfax program. The syntax for this command from the man page is
Server processes can be configured to answer incoming phone calls and automatically receive faxes. Received documents are placed in the recvq subdirectory as TIFF Class F files. The server can be configured to make these files publicly accessible, or they can be made private, in which case an administrator must manage their delivery.
When a fax is received, the server process invokes the bin/faxrcvd command. The default command is a shell script that sends a mail message to a well-known user, the FaxMaster, but you might also, for example, automatically spool the document for printing.
Actually the man pages for HylaFAX are well written (for man pages). In the man pages
for faxd, you get a lot of detailed information about how received faxes are handled.
HylaFAX comes with several features from creating cover pages and
receiving incoming data calls to handling polling requests. In each of these cases you can
get more information for the man pages for each command discussed in the remainder of this
chapter.
You generate PostScript cover sheets for your outgoing faxes with the faxcover command. The syntax for this command from the man page is
HylaFAX supports the polled retrieval of fax documents. Documents
received because of a poll request are stored in the recvq subdirectory and also delivered
directly to the requester using the bin/pollrcvd command. This script typically encodes
the binary fax data and returns it to the recipient via e-mail.
Most fax modems also support non-fax communications. HylaFAX uses
the locking mechanism employed by uucp and cu. Therefore, HylaFAX transparently
relinquishes the serial port when an application uses the modem for an outgoing call. In
addition, HylaFAX attempts to deduce whether an incoming call is for fax or data use. If
an incoming call comes from a data modem and the -g argument is specified in the
configuration file (or on the command line when the fax server process is started),
HylaFAX invokes the getty program so that the caller may log in to the system.
HylaFAX maintains status information in several forms. General status information for each server process can be displayed by the faxstat(1) program. The server processes may also be configured to log various kinds of debugging and tracing information. For more information about configuration, see the section entitled "Installation Steps" in this chapter. The faxstat utility provides information such as the remote status of jobs queued for transmission, jobs received, and the general status of server processes. See Listing 59.3.
Listing 59.3. Output of the faxstat command.
It is easy to set up a simple mail-to-fax gateway facility with HylaFAX. If your system uses sendmail to deliver mail, follow the instructions in the faxmail/mailfax.sh-sendmail document. If your system uses smail (Linux users), follow the instructions in faxmail/mailfax.sh-smail. Restart your mail software.
Now, mail to user@dest.fax will be formatted and submitted as a facsimile job to user
at the specified destination. By writing a more involved mailfax script, you can add
options and display parameters such as different resolutions by parsing the user string.
See the faxgateway documentation on www.vix.com in HylaFAX/faxgateway.html or the
/sgi/fax/contrib/dirks-faxmailer/README on sgi.com for more information.
HylaFAX stores its data, configuration, and faxes in several places on the file system in Linux. Here is a list of the important files and directories:
HylaFAX supports multiple fax modems on a single host. Associated
with each modem is a server process that handles transmission and asynchronous reception.
Server processes operate independently of each other and use file-locking to avoid
conflicts when handling jobs submitted for transmission. All modems are treated equally at
the same priority. A HylaFAX server process accepts messages and commands through FIFOs. A
FIFO is basically a communications data channel where the first data in (FI) is the first
data out (FO).
The mgetty+sendfax+vgetty package is a set of programs to send and receive faxes in a UNIX environment. The package only supports Class 2 modems. The filename is called mgetty+sendfax-0.98.tar.gz, and you can get it from tsx-11.mit.edu in the /pub/linux/sources/sbin directory. There are three parts to this package: sendfax, vgetty, and mgetty. The program mgetty is for receiving faxes and handling external logins without killing any outgoing calls. sendfax is a program that sends fax files. vgetty is an extended version of mgetty that can answer the telephone like an answering machine and record voice-mail messages in addition to mgetty's fax or data call handling capabilities. The entire package lets you manage faxes and voice messages.
So what's the difference between mgetty and the regular versions of getty? Unlike traditional versions of getty or uugetty, which will put a modem into auto-answer mode, mgetty does not. When a call comes in, mgetty tells the modem to answer and tell mgetty what kind of call is being received. If it is fax, mgetty will receive the fax itself. If the modem is getting data, mgetty prompts for a user ID, and then hands the open line off to login for a normal data login.
It's the modem's job to distinguish a fax call from a data call. Not all fax modems can do this, so if yours does not do this, there is no way for mgetty to do this for you. mgetty can be used with modems that cannot distinguish a fax call from a data call, but you must tell it ahead of time what type of call to expect. You can configure mgetty to allow for uucp and other connections.
Note that mgetty also supports caller ID and can be programmed to deny connections based
on originating telephone number.
If you have a voice-capable modem, then you can use vgetty. The vgetty program is an extension to mgetty that provides additional call-handling capabilities. When the modem reports an incoming call, vgetty has the modem pick up the line and play a greeting. Then, as with mgetty, the modem reports the type of call. If it hears "human voices" (stuff it can't identify), the modem reports a voice connection and vgetty records the noise as an incoming voice message. If the modem reports that it identifies a fax tone, vgetty acts like mgetty and receives a fax or answers a poll. If instead, the modem hears nothing following the greeting (a certain level of silence that continues for a certain number of seconds), the modem assumes the caller is a data modem and attempts a data connection.
Do not use vgetty if you expect a large number of voice calls and very few data calls on
the phone line you hook up. Most modems will hang up during the incoming message.
Basically the sendfax portion does the following:
You will need the Portable Bitmap Toolkit (pbmplus) for converting from the standard G3 fax format to printable images. The reason is that mgetty itself can only send or receive G3 (raster) format. However, the distribution includes tools to convert raw G3 files to or from the format used by pbmplus. The pbmplus toolkit is available from tsx-11 or sunsite archives. You will have to use the pbmtog3 and g3topbm utilities in mgetty to convert between PBM and G3. Also, the Ghostscript interpreter can convert PostScript to G3, but not vice versa.
To compile the package, copy the policy.h-dist over to the policy.h file. Then run make all to make all the packages.
To enable logins with fax capability, replace the getty with mgetty (or vgetty if your modem can handle voice) for the /dev/tty device you have configured for incoming calls. To send faxes, you have to use sendfax. The syntax for the command is:
| -p | Tells sendfax to try fax polling, that is, get any documents queued in the remote fax machine for you. |
| -x | Uses the given level of verbosity for logging0 means no logging, 5 is really noisy. |
| -v | Gives some progress report on stdout. |
| -l | Uses the given modem lines. Multiple lines can be separated by a colon. Example: sendfax -l tty1a:tty2a |
| -m | Sends an
additional init string. This string is sent right after initializing the modem and setting
it into Class 2 mode. You can use this to set the speaker value, some special registers,
and so on. The modem must return "OK." If it returns "ERROR," sendfax prints an error message and aborts. You do not have to prepend the "AT" prefix, but it won't do any harm either. |
| -d | Specifies the directory where polled fax files should go to. Defaults to the directory from which the program was invoked for the current directory. Unused if not polling a fax. |
| -C | The values for class are the type of modem: "auto" (the default), or "cls2." |
| -S | Assumes modem connection on stdin, do not try to lock or initialize anything. To take over existing connections use with a dial string of T1. The T1 command sends out a short beep and no phone number at all. Such a behavior would confuse many modems. In the case of a pulse dialed number, this action may confuse the telco switch. You may also use the -m ATX1 option with the -S option if you do not wait for dial tone. |
| -n | Tells sendfax to send the fax pages in "normal" (204´98 dpi) mode. Default is "fine" mode (204´196 dpi). |
Now that we have discussed all these options, you may be happy to know
that none of these options are required to send a fax. So the following command by itself
will send out a fax:
From the FAQ, the note about the copyright is as follows:
"The mgetty+sendfax package is Copyright " 1993 Gert Doering. You are permitted to do anything you want with this programredistribute it, use parts of the code in your own programs, _, but you have to give me creditdo not remove my name.
"If the program works for you, and you want to honour my efforts, you are invited to donate as much as you want.
"If you make money with mgetty, I want a share. What I mean by that is: it's perfectly OK with me to get paid for mgetty installation or support, but if you want to actually sell mgetty, or pack mgetty with a modem and sell it as "UNIX FAX package," contact me first."
This package is still BETA software. Use it at your own risk, there is NO warranty. If it
erases all the data on your hard disk, damages your hardware, or kills your dog, that is
entirely your problem. Anyway, the program works for me and quite a lot of other people.
For more info on the copyright issue, please contact Mr. Doering directly.
The FAQ has some interesting questions and answers to the commonly found bugs, "features," and fixes. In most cases, if your modem is not supported, twiddling with a few files here or there will not do the trick. I tried four different types of known name-brand modems before a cheap clone modem worked. I have no idea why this modem, which by the way has no visible markings, worked whereas the others did not. You may have better luck than I did.
In short, trying to fax out of Linux may not be as easy as you think. It's possible,
but will take time and effort on your part.
This is a brief introduction to HylaFAX, a complete fax-handling package for UNIX and Linux. I covered the following items in this chapter.
The source code for HylaFAX is available for public FTP on ftp://<a name=/ftp.sgi.com">ftp.sgi.com as /sgi/fax/source/ hylaFAX-v3.0.pl0-tar.gz.
I have also introduced you to sendfax, mgetty, and vgetty. These three programs enable you to send faxes, receive faxes, and even set up voice mail on your Linux box, provided your modem is supported.