[LinuxFocus-icon]
LinuxFocus article number 249
http://linuxfocus.org

[Mark]
by Mark Nielsen
<articles(at)audioboomerang.com>

About the author:
Mark Nielsen works at AudioBoomerang.com which creates, delivers, and tracks personalized multimedia email, web, and newsletter campaigns. He works as a consultant delivering end products to AudioBoomerang.com clients, such as advanced customized statistical reports used for demographic or pyschological profiles for future campaigns. In his spare time, he writes articles relating to Free Software (GPL) or Free Literature (FDL) and is involved with the non-profit learning center eastmont.net.

Receiving faxes with efax.

[illustration]

Abstract:

Setting up Efax to send and receive faxes on RedHat 7.2.

_________________ _________________ _________________

 

Purpose

I wanted to setup a fax server. I thought about using HylaFax, but my RedHat system already had mgetty installed which clashed with HylaFax when I tried to install the HylaFax rpm. Also, it seems like if I do it right, I might be able to use mgetty to do logins and voice sessions as well as fax sessions. For now, I just wanted to receive faxes with the default installation of RedHat 7.2 without additional software.

Efax and fax are really the same thing. 'fax' is just a script calling efax.

 

Config Files

There are two files you can configure to get things working : /usr/bin/fax and /etc/inittab.

Copy /usr/bin/fax to /usr/bin/fax_custom, and I changed the following lines:

FAXDIR=/var/spool/fax/incoming
NAME="AudioBoomerang.com Computer Fax Server"
FROM="+1 111 222 3333"
ANSFNAME="fax_%Y%m%d_%H%M%S"

In /etc/inittab, I changed:

S0:2345:respawn:/bin/sh /usr/bin/fax_custom answer
 

Efax and fax -- single receive

To receive a single fax because you know someone is calling you with a fax, execute this command:
efax -d /dev/ttyS0 -l "268 1162"  -c 1,5 -r reply
or
fax answer

If you don't want to have fax spawn in the background waiting for the next fax connection, then don't add changes to /etc/inittab I mentioned in the "Config Files" section.

 

Efax and fax -- multiple with inttab

If you changed the /etc/inittab file as I described in te "Config Files" section, just reboot your computer and your modem will receive faxes and dump them into the /var/spool/fax/incoming directory.

If you issue the command:

ps auxw | grep efax
you should see the efax session running in the background, like:
root 1698 0.0 0.4 1576 616 ? S< 21:47 0:00 /usr/bin/efax -v -v chewmainrxtf -d/dev/modem -iZ -i&FE&D2S7=120 -i&

The nice thing is, if you kill the process id "1698", it will respawn and I believe reread the /usr/bin/fax_custom file. Thus, if you make changes to that file, just kill the process running efax before you try to fax to it when you want to test your configuration.

 

What do you do after you receive faxes?

Well, run a cron job that sorts the files in /var/spool/fax/incoming, creates a lock file for each group of faxes, and then either convert them to pdf for viewing on the web or directly print them out.

If you want to print it out, use efix like,

efix -ops fax_20020606_014847.001 | lpr

I would recommend that you print the file and then store it in a backup directory.

 

Sending faxes

Setting up the print service was much tougher than I had thought. First, do what the manpage says (with some alterations):
  1. ln /usr/bin/fax /usr/bin/faxlpr
    
  2. In /etc/printcap.local
       fax:lp=/dev/null:sd=/var/spool/fax:if=/usr/bin/faxlpr_perl:
    
  3.     mkdir /var/spool/lpd/fax
        touch /var/spool/lpd/fax/lock
    
  4. /etc/rc.d/init.d/lpd restart
    

Now my changes are as follows:

  1. In /usr/bin/faxlpr, I changed
    l=`$FAX send "$num" fax$$`
    to
    
    `gs -q -sDEVICE=tiffg3 -dNOPAUSE -sOutputFile=fax_out fax$$ </dev/null`
    l=`efax -t $num fax_out`
    `rm fax_out`
    
    and also changed these three lines in the faxlpr section:
      num=` echo "$cfile" | sed -e /^[^J]/d -e s/..//`
      host=`echo "$cfile" | sed -e /^[^H]/d -e s/..//`
      user=`echo "$cfile" | sed -e /^[^P]/d -e s/..//`
    
  2. I saved a perl script at /usr/bin/faxlpr_perl and did chmod 755 /usr/bin/faxlpr_perl:
    #!/usr/bin/perl
    
    my $String = "";
    foreach my $Arg (@ARGV)
      {
      if ($Arg =~ /\-j/)
        {
        my $Copy = $Arg;
        $Copy =~ s/\-j//;
        open(FILE,">lock"); print FILE "hfA$Copy"; close FILE;
        }
      }
    my $Command = "/usr/bin/faxlpr";
    system ($Command, @ARGV);
    print 1;
    
  3. This part I really hate, but I had to "chmod 666 /dev/ttyS1" so that the lpr user which controls print jobs can use the modem.

The perl script make it so faxlpr can find the process number and changing the "fax" command to "efax" was required because it attempted to create lock files which I didn't want it to create.

I believe my method of sending faxes also breaks the lock files, so it might screw up if you try to send a fax while it is receiving one.

After all this pain and suffering, your program that prints needs to be able to specify the "-J" option so that it can do a command like 'lpr -P fax -J "555 1212" file.ps'. Otherwise, print to a file and then print that file out with a line command.

Also, you could just use the efax command to send out a fax and not do it through the print service. You have to use gs to convert it before you send it out, which is still a pain.

 

Conclusions.

Whenever I get the chance, I will try and see if I can:

Efax is only a temporary solution before I figure out how to get mgetty to work (which I tried to but failed). The only reason why I didn't use hylafax was because it clashed with mgetty when I tried to install the rpm and then I got interested in mgetty, and then diverted with efax. I am going to try and use mgetty in the future since I would like voice and login sessions as well with the same modem. It seems like it might be possible to use voice, login, and fax all on the same modem -- but it seems like there might be some problems with some modems to properly detect fax vs voice vs login. I really don't like sending out faxes with efax and the print service. I hope mgetty will solve some issues I had.

 

References

  1. The Easy Fax Server!
  2. A Linux Fax Server for a Windows Network
  3. Linux Fax for Dummies
  4. Hylafax

Article Version 1.2 : Date Last Changed Thu Jun 13 04:17:31 2002



Webpages maintained by the LinuxFocus Editor team
© Mark Nielsen
"some rights reserved" see linuxfocus.org/license/
http://www.LinuxFocus.org
Translation information:
en --> -- : Mark Nielsen <articles(at)audioboomerang.com>

2005-01-14, generated by lfparser_pdf version 2.51