Saturday, April 28, 2012

How I used Linux as a Multi Line Fax Server for a Pharmacy Order System

Summer of 1995.

My boss came to me and said "Jim, I need a fax machine in our new out-of-state office that can refax the orders to us here at the main office." 
     I promised that I would look into the possibilities immediately.  I started by calling my main parts vendor but was unable to find anything at the time for either Windows 95 or Windows NT that was a multi-line fax server and could also refax the received faxes to our main office. 
     I had been using a small utility with my home Linux system and had configured efax to work with one modem line.  Sure enough the main controlling program was just a shell script and was extremely well documented with comments.  In fact there were more lines of comments than of code. 
     After messing around that night faxing things back and forth from my home and the office I decided that efax could do the job.  I went to my boss and told him that there were no commercial products that would do what he wanted, but that I had found a solution that would work.  What he wanted to do was a minor problem with UNIX because controlling banks of serial devices is one of the reasons that UNIX was written by AT&T in the first place. 
     He was hesitant to go with a UNIX solution until I assured him that a company called Caldera was working with Novell to provide a UNIX operating system that would run on regular IBM compatible hardware and be interoperate with our network.  He gave me the go ahead. 
     Since the system was going to be in an other state I decided to go with new, powerful equipment so as to have as few problems as possible. I got the quotes that I needed and ordered a copy of Caldera 1.0,  100 MHz Pentium, 16 MB RAM, 1.2 GB HD, mini tower case, NE2000 combo network card, 4x EIDE CR-ROM player, 8 port ISA Cyclades serial board with octopus cables, 4 USR Sportster 14.4 external modems, and an HP 5 laser printer.  The grand total came up to about $2000.00. 
     All the parts came in by the second day and I assembled the hardware in a few minutes.  I then placed the Caldera CD-ROM in the player and the boot disk in the floppy drive and quickly ran through the setup to have an operational OS in less than 10 minutes.  This was the first time that I had ever used Redhat and I haven't used anything else since then for any full installs. 
     The system didn't recognize the Cyclades serial card.  No problem, I was an old hand at reconfiguring and installing the kernel.  Still didn't recognize the Cyclades serial card.  I double check everything that I had done and it was correct.  I called Cyclades technical support and they knew exactly what was wrong and directed me to a patch on the internet.  I got the patch and had full instructions.  I applied the patch, setup the /etc/rc.d/rc.serial file to recognize the new ports,  created the new devices in the /dev directory with a supplied script and remade the kernel. 
     With problems I had the entire system operational inside of two hours.  It even installed Samba print and file server and the Apache web server and they were running with no configuration on my part. 
     Now came the tough part.  I copied the /usr/bin/fax script to /usr/bin/faxa.  Then I modified the /usr/bin/faxa script as follows: 
I changed the 
     DEV=modem 
to 
     DEV=ttyS0 
I changed the 
     NAME="" 
to 
     NAME="name of our company" 
I corrected the phone number to report the phone number that it was going to answer at.  I also fixed the log name and received fax names to give each a unique name by prepending an 'a' to these names. 
     Then I made sure that /usr/bin/faxa worked in that it would answer the line receive the fax, print the fax locally, retransmit the fax to our bank of fax machines in the office and then move this file to a done directory. 
     Finally I copied /usr/bin/faxa to /usr/bin/faxb, /usr/bin/faxc and /usr/bin/faxd and corrected each of these new files so that  DEV= ttyS1, ttyS2 and ttyS3 respectively.  They each prepended the log file name and received fax file names with 'b', 'c' and 'd' respectively. 
     I spent the next two days testing the system to ensure that it would work without any hardware or software problems.  The following day I made the 3 hour drive and installed the system.  I had to modify the print portion of the /usr/bin/fax[a|b|c|d] scripts in order to fix a glitch in the information that was being sent to the system from some old fax machines.  The efax machine was rescaling the faxes so that one page faxed would fit on one printed page.   We were getting a postage stamp printed page in the upper left corner with a long thin horizontal line clear across the page.  I modified the faxa, faxb, faxc and faxd scripts to trim the page to 8.5x11 and cleared up the problem. 
     In less that a week I had researched, developed and implemented a multi-line fax server.  I never saw the utilization go below 85% on that box and there was always plenty of free memory.  And the thing that amazed me is that we were only scratching the surface of the power that having a Linux system could provide.
     The system worked with only a few minor user glitches during the next nine months that I worked at that company.  Once the phone lines became messed up.  The users forgot to put paper in the printer upon occasion or didn't change the toner until two days after the printer ran out.  "Oh, you mean it's _supposed_ to have stuff printed on the page?" 
     Even a complete unexpected power down would only cause the system to come back online reprint and refax what it hadn't moved to the done directory and then continue on answering the fax lines.  Please note that this is the default behavior of the operating system and efax,  I didn't have to do anything special to get this robustness. 
     Next I tell you how I automated putting the received faxes into a web server. 

No comments:

Post a Comment