Search:  
Gentoo Wiki

Fax


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Introduction

To get a working printer/fax on the linux machine you should have some software and fax modem.

The Printing software will be using the fax software as a print filter. The efax will find the fax number from the print Job number and will send the fax. The efax software was written by Ed Casas <edc@cce.com>.

The efax Software

#emerge efax

The printcap entry.

edit /etc/printcap and add following lines:

File: /etc/printcap

....

fax:\
     :lp=/dev/null:\
     :sd=/var/spool/fax:\
     :if=/usr/bin/faxlpr:

Use hard link and not symbolic link to the fax command.

ln /usr/bin/fax /usr/bin/faxlpr

The /dev/modem special file.

i have external modem on COM2 which is /dev/ttyS1, to control yourself you can emerge minicom and try to dialout in settings you will find what port did it use.

chmod 666 /dev/ttyS1
ln -s /dev/ttyS1 /dev/modem

UDEV rule

Udev rule is common way in modern system to control devices, so let's use it.

With root privileges run udevadm monitor and plug in your modem (cell phone in my case) output would be similar to

udevmonitor will print the received events for:
UDEV the event which udev sends out after rule processing
UEVENT the kernel uevent

UEVENT[1222919713.932586] add      /devices/pci0000:00/0000:00:02.2/usb2/2-2 (usb)
UEVENT[1222919713.935620] add      /devices/pci0000:00/0000:00:02.2/usb2/2-2/2-2:1.0 (usb)
UEVENT[1222919713.936701] add      /class/tty/ttyACM0 (tty)
UEVENT[1222919713.937859] add      /class/usb_endpoint/usbdev2.15_ep81 (usb_endpoint)
UEVENT[1222919713.937877] add      /devices/pci0000:00/0000:00:02.2/usb2/2-2/2-2:1.1 (usb)
UEVENT[1222919713.938988] add      /class/usb_endpoint/usbdev2.15_ep86 (usb_endpoint)
UEVENT[1222919713.939006] add      /class/usb_endpoint/usbdev2.15_ep02 (usb_endpoint)
UEVENT[1222919713.939016] add      /class/usb_device/usbdev2.15 (usb_device)
UEVENT[1222919713.939025] add      /class/usb_endpoint/usbdev2.15_ep00 (usb_endpoint)
UDEV  [1222919713.948476] add      /devices/pci0000:00/0000:00:02.2/usb2/2-2 (usb)
UDEV  [1222919713.951484] add      /devices/pci0000:00/0000:00:02.2/usb2/2-2/2-2:1.1 (usb)
UDEV  [1222919713.973104] add      /class/usb_endpoint/usbdev2.15_ep86 (usb_endpoint)
UDEV  [1222919713.973799] add      /class/usb_endpoint/usbdev2.15_ep02 (usb_endpoint)
UDEV  [1222919714.041774] add      /devices/pci0000:00/0000:00:02.2/usb2/2-2/2-2:1.0 (usb)
UDEV  [1222919714.042651] add      /class/tty/ttyACM0 (tty)
UDEV  [1222919714.071656] add      /class/usb_endpoint/usbdev2.15_ep81 (usb_endpoint)
UDEV  [1222919714.092331] add      /class/usb_endpoint/usbdev2.15_ep00 (usb_endpoint)
UDEV  [1222919714.100161] add      /class/usb_device/usbdev2.15 (usb_device)

at this point CTRL+C and add entry in the /etc/udev/udev.rules/99-local.rules

File: /etc/udev/udev.rules/99-local.rules
# Create symlink for a USB modem
KERNEL=="ttyACM0", SYMLINK+="modem", GROUP="uucp"

and then reload rules

udevadm control --reload_rules

Make sure users who have to use fax are in the uucp group

vigr

The /usr/bin/fax file

Edit the /usr/bin/fax to your preferences:

File: /usr/bin/fax
# --- Start of user configuration section ---
FAX=fax
EFAX=efax
EFIX=efix
DEV=modem
FROM="+1 XXX XXX XXXX"
NAME="YOUR NAME HERE"
PAGE=letter
PRTYPE=ps
PRCMD="lpr"
VIEWCMD="xloadimage stdin"
GS=gs
DIALPREFIX="T"
DIALSUFFIX=""
LOCK='-x /var/lock/LCK..$DEV' 
 FCINIT="$FCINIT -j+FBO=0"
CONFIGFILES="/etc/efax.rc ${HOME:-~}/.efaxrc ./.efaxrc"
TSTAMP='date +%m%d%H%M%S'
LOOKUP='eval sed -n -e "/^fax($1):/{" -e "s/^[^:]*://p" -eq -e"}" $f'
DIRFILES="${HOME:-.}/.faxdir"
TELCVT='sed -e s/+1/1/ -e s/+/011/'
PAGE_letter="8.465x11in"
PAGE_legal="8.465x14in"
PAGE_a4="21x29.7cm"
RES=204x196
PRINT='$EFIX -ve -p$PAGEDIM -r300 -s0.98 -d0,0.125 -o$PRTYPE $f'
VIEW='$EFIX -ve -p$PAGEDIM -r300 -opgm $f'
INIT="-iZ -i&FE0&D2S7=120 -i&C0"
RESET="-kZ"
SPKR="-iM1L0"
 CLASSINIT="-o0"
RXINIT=""
TXINIT=""
DATECMD='date "+%Y/%m/%d %H:%M"'
HDR='$DATE     $FROM      $NAME     p. %d/%d'
BUSYRETRIES="30 60 120 300 60 600 60 60 1200 60 60"
FAILRETRIES="300 300"
NICE="nice -n -10"
RM="/bin/rm -f"
LS="/bin/ls"
VERB="ewin"
VERBLOG="chewmainrxtf"
CONSOLE=/dev/console
FAXDIR=/var/spool/fax
LOGDIR=/var/log/fax
ANSFNAME="%Y%m%d-%H%M%S"
UMASK=022
FAXMGR=deem
SENDMAIL=/usr/sbin/sendmail
NOTIFY='faxmail | $SENDMAIL $FAXMGR'
ANSRINGS=4
DATAOPT="-j&C1 -j+FCLASS=0 -jS7=30"
DCMD="exec /sbin/getty -h $DEV %d vt100"
FONE=/usr/bin/fone
VCMD="exec $FONE %d"
OWNER=root.tty
MODE=666
NOLOG='[145]'
# ****************************************************************
# --- End of user configuration section ---
# ****************************************************************

changes in line 586

#     cfile=`tail -1 lock` <-- comment out and add next 2 lines
      cfile=`/usr/bin/tail -1 lock`
      cfile=`< $cfile`

at lines 586,587 there shouldn't be '-' signs the lines are:

       0) echo "$l" | mail -s "fax to $num succeeded" $user@$host ;;
       *) echo "$l" | mail -s "fax to $num failed   " $user@$host ;;
my file was correct, so just check it

Please use the TIP Strip comments when posting config files

The /var/spool/fax directory

create the directory /var/spool/fax

mkdir /var/spool/fax
chmod 777 /var/spool/fax

The /var/lock directory.

change the mode at the /var/lock directory

chmod 1777 /var/lock

CUPS integration


Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process


fax4CUPS is a very simple shell script that acts as a CUPS backend for a serial fax modem. Essentially, you print with lpr and the fax is sent. The nice thing is that you have CUPS around, and this means, for instance, that you can check whether your fax has been sent just using your favorite browser (as you would do for any other printer), even if the fax modem is really on a remote server. It supports efax, HylaFAX, and mgetty-fax.
emerge fax4cups
/etc/init.d/cupsd restart
  1. point your browser to http://127.0.0.1:631/
  2. and add printer
Name:fax
Location:localhost (optional)
Description:fax
  1. device: lpd/lpr HOST or PRINTER
  2. Device URI: efax://localhost
  3. Make: efax
  4. Model: efax

Usage

Console commands

Control printers in Linux from the command line thats for right now

How to print from GUI applications


Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process


Converting postscript documents into fax files

man efix

TODO
have to find a way for other file types, like *.doc *.pdf
$ fax make doc.ps

doc.ps.001, doc.ps.002 etc. will be created in the same directory. These files are tiffg3 format, and you can look them up by using gqview, kfax, or ghfaxveiwer.

Sending faxes manually


Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process


TODO
somewere i fogot to set permission, so using sudo
$ fax send 03-3999-9999 doc.ps.0*

Sending faxes in background


Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process


TODO
that doesn't work, the printjob just sitting there
lpr -P fax -J <Fax-Number> [file-names]
any command | lpr -P fax -J <Fax-Number>

i.e.

$ lpr -P fax -J 03-3999-9999 doc.ps

How do I use it from other Unixes on the net ?


Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process


TODO
for users who used this scheme, please live a note how it shoud be

Add the following entry into the /etc/printcap file on the client Linux systems and create the spool directory, and so on ...

File: /etc/printcap
  fax:\
      :sd=/var/spool/fax:\
      :mx#0:\
      :sh:\
      :rm=host.domain:\
      :rp=fax:

add the name of the client hosts into the /etc/hosts.lpd on the fax server machine. use it as before.

On the remote host (bar), make a remote printer named like 'fax', remote host name to be of the host efax running (foo), remote queue 'fax' and use 'postscript printer' as the print filter. Now you can use on the host bar same as local,

$ lpr -P fax -J 03-3999-9999 doc.ps

Note: The header string that efax adds to the fax pages is not effected by the user name that sends the fax. (can be updated).

How do I use it from MSWindows on the net ?


Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process


TODO
for users who used this scheme, please leave a note on how it should be

Install and run samba on the host efax is running (foo). Confirm the host(foo) and the fax can be seen from the windows machine(win) in the Network-Computers. On the windows machine(win), make a remote printer named like 'fax', selecting remote printer 'fax' under the host efax and samba is running(foo), and use 'Postscript Printer' as the printer model.

On the windows machine(win), save the document as the fax number, like '03-3999-9999.doc' . The extention should be '.doc' if the document is a Microsoft Word document.

Print the file '03-3999-9999.doc' selecting the remote printer 'fax'.

Special characters

Use '_043' in place of '#', '_052' in place of '*', and '_054' in place of ','(comma).
For example, '_0431_0522' means '#1*2'.

TODO

have to connect efax and cups

convert fax images into pdf files

See Also

Fax software

Proprietary fax software

Retrieved from "http://www.gentoo-wiki.info/Fax"

Last modified: Wed, 08 Oct 2008 08:51:00 +0000 Hits: 29,426