APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

VSI-FAX is a popular commercial fax application. Although it can be used for desktop faxing and for inbound faxes, the most common use is probably automated faxing of documents printed by some application.

A "printer" that faxes isn't hard. Here's a model script for Sys V printers:

# ignore most arguments
open(I,$file) or $err=$!;
@stuff=<I>;close I;
#  this is just for debugging 
foreach(@stuff) {
   print O "$x :$_";
close O;
# The fax number is on the 12th line of the form
$faxnum=~ tr/0-9//cd;
chomp $faxnum;
$faxnum=~ s/^  *//;
$faxnum=~ s/  *$//;
#  We also pick up a custom tag - the vendor name
$tg1=~s/ /_/g;
# if no fax number print a message to a different printer
if ($err or not $faxnum) {
  open(O,"|/usr/bin/lp -dRECEIVING");
  print O "Fax request from $login problem\n";
  print O "No faxnumber $faxline \n" if not $faxnum;
  print OO "Fax request from $login problem\n";
  print OO "No faxnumber $faxline \n" if not $faxnum;
  print O "===============\n";
 foreach(@stuff) {
   print O $_;
   print OO $_;
close O;
close OO;
exit 0;

$cmd="/usr/vsifax/bin/vfx -t tg1=$tg1 -n $faxnum $file";
# just for debugging again
print O "POFAX $login $cmd\n";
close O;
# spools the fax to vsifax
exit 0;

Notice the line that handles "tg1". VSI-FAX has four custom tags that you can use for any purpose. These won't be part of the outgoing fax, but we can access them in vfxolog. We'll see that shortly. First, let's see how we'd use this script.

For System V spoolers, you'd put the script in the lp model directory. For example, that's /usr/spool/lp/model on SCO. I called it POFAX, and created my fax printer as follows:

/usr/lib/lpadmin -p POFAX -v /dev/null -m POFAX
/usr/lib/accept POFAX
enable POFAX

For CUPS, I might use the socket idea presented at CUPS (Common Unix Printing System) print to file - the hard way!. I like that better than messing with configuration files. It's also fairly portable - if the spooler system can go to a network port, you can do it that way.

To see the tags, you need to tell vfxolog what you want to see. I do that with this "vflog" script:

$cmd="/usr/vsifax/bin/vfxolog -f \"seq,sbt,npg,nps,tfn,ars,rrs,att,tg1\"";
$hdr="Req-id  -Submitted-     npg nps  Phone number     Attmpt Result att  Vendor\n";
print $hdr;
foreach ( @stuff) {
  @line=split /,/;
  $line[1]=substr($tm,0,4) . "/" . substr($tm,4,2) . "/" . substr($tm,6,2);
  $line[1] .= " " . substr($tm,8,2) . ":" . substr($tm,10,2);
  $line[4]= substr($tm,0,3) . " " . substr($tm,3,3) . "-" . substr($tm,6);
  $save="$line[0]   $line[1]   $line[2]   $line[3] $line[4]     $line[5]  $line[6] $line[7] $line[8]";
  print "$save\n";
  if ($cnt == 10) {
    print "More... ";
    exit 0 if $m =~ /[qQ]/;
    print $hdr;
    $cnt %= 10;

You could make this much neater; I didn't make the extra effort to align fields (that's easily done with "printf").

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> Print to FAX with custom tags

Inexpensive and informative Apple related e-books:

Take Control of Pages

iOS 8: A Take Control Crash Course

Photos: A Take Control Crash Course

Take Control of Parallels Desktop 12

Take Control of Upgrading to El Capitan

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

I was taught that the human brain was the crowning glory of evolution so far, but I think it’s a very poor scheme for survival (Kurt Vonnegut).

Linux posts

Troubleshooting posts

This post tagged:


Fax Software


Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode