Thursday, June 10, 2010

Installing PHP mcrypt extension under Snow Leopard (Mac OS X Version 10.6.3)

Step 1

Enable php in /etc/httpd.conf by uncommenting (remove # at the start of line) the following line

LoadModule php5_module libexec/apache2/

Step 2

a) Download libmcrypt from

b) Extract the contents to ~/Downloads/libmcrypt-2.5.8

c) In Terminal type the following commands

cd ~/Downloads/libmcrypt-2.5.8/
./configure --disable-posix-threads --enable-static
sudo make install

Step 3

a) Download source code of PHP 5.3.0 from

b) Extract the contents to ~/Downloads/php-5.3.0

c) In Terminal type the following commands
cd ~/Downloads/php-5.3.0/ext/mcrypt
cd modules

sudo cp /usr/lib/php/extensions/no-debug-non-zts-20090626/

Step 4

a) Set your default timezone in php.ini located at /etc. Mine is

date.timezone = Asia/Kolkata

b) Enable the mcrypt extension by typing/editing the following in php.ini


Step 5

Restart apache with the following command in Terminal

sudo apachectl restart

Step 6

1) Test your php installation by creating a test.php file in /Library/WebServer/Documents
with the following contents

2) Open a browser and go to which should
list the version and other details regarding PHP.
You should also see a section with mcrypt details.

Saturday, June 05, 2010

Printing from lpt1 port of legacy DOS application running under Windows XP to a file and converting it to PDF format

Create PDF files instead of real printing (save some trees) from legacy DOS applications that output to HP's PCL format on lpt1 port

  • DOS application prints directly to lpt1 port in HP's PCL format
  • No real printers having PCL capability installed
Procedure for printing to file

  1. Install a PCL capable printer under Windows XP such as HP's LaserJet 6L even though you don't physically have the printer.
  2. Go to Printers and Faxes under Control Panel and select properties of the newly installed printer. Under Ports select FILE: - this will make the printer print to file
  3. Enable sharing on the printer and give it a share name such as HPLJ
  4. Open command prompt and type net use lpt1 \\foobar\hplj (where foobar is your computer's name)
  5. Open command promt, create a test file (for example test.txt) and check if the above is working by giving print test.txt at the promt. A pop-up window will appear asking for file name, give a name such as c:\test.prn and check that the file has been created. If this works, the printing to file is working as expected.

The above creates a PCL printer that prints to a file and thus it is not necessary to physically have the printer. We redirect all output to lpt1 from the DOS application to this shared printer which then prints it to file.

Procedure for converting the PRN to PDF

Follow the detailed procedure as shown at but I couldn't get the right-click menu stuff working. So I always use the command pcl2pdf input.prn output.pdf on the command prompt. If you don't want to compile or don't know how to compile you can download the GhostPCL windows binary from

Use Ghostscript and GhostPCL to convert PCL formatted files to PDF. It worked fine even with DOS applications printing complex graphical plots using PCL.

Side Note
If you work exclusively on the DOS OS and don't have networking installed you can downlaod the prindir utility from to redirect the lpt1 port to a file. I tested with the following command c:\utils\prindir /c - this installs prindir to memory and then redirect lpt1 to file report.prn by c:\utils\prinmod /GET1 /PUT9 /FILE-c:\report.prn (as I put the files under directory utils). Please note that prindir is not a free software, hence I only used it for testing purposes. I don't use it anymore. There are heaps of port capture softwares for DOS but none worked with PCL files as outputed by my legacy DOS application except for prindir. Please note that this procedure will not work with Windows XP or later versions since now the OS doesn't allow direct hardware access to applications. It might work with Windows 95 and Windows 98 but I have not tested it.
How to enable networking in a MS DOS virtual machine running under VMware

Things you need

MS Dos Networking Client:
Download Disk3-1.exe and Disk3-2.exe from and put them each in its own folder. For example, make a folder Disk1 and put Disk3-1.exe in it. Similarly put Disk3-2.exe in a folder called Disk2. Extract the contents by double clicking on each.

Floppy Drive: Copy the extracted files from Disk1 into floppy 1 and Disk2 into floppy 2 (you don't need to copy the Disk3-1.exe and Disk3-2.exe to floppy) . If you don't have a physical floppy drive, no need to despair, just create virtual floppy drives and images using an excellent free software called Virtual Floppy Drive (VFD) for Windows NT platform from I personally used this to create .flp files which can be used as floppy drive images under VMware. Rest of the instructions will be as per the virtual floppy images Disk1.flp and Disk2.flp

Network Driver:
Download and extract in a floppy or create a virtual floppy image (pcnet.flp) of the AMD PCNet Dos drivers from

  1. Boot into MS DOS
  2. Use Disk1.flp as the floppy image and type A:\setup
  3. Follow the prompts for installation and when the Network Adapter List is shown select Advanced Micro Devices AM2100/AM1500T
  4. Select user name, computer name as per your desire
  5. Under Network Configuration delete the default protocol NWLink IPX Compatible Transport and select Microsoft TCP/IP
  6. Select Network Configuration is correct
  7. It will prompt you for the OEM drive disk, at that point select Disk2.flp and continue installation. In the end again the Network Client disk will be asked and you will have to select back Disk1.flp as the floppy image.
  8. After installation remove the floppy images and reboot.
  9. You will get errors regarding NEMM.DOS not found.
  10. Load the pcnet.flp image and copy pcntnd.dos and pcntnd.nif to C:\net (if you installed the networking client in another place, change accordingly).
  11. Change folder to C:\net , open SYSTEM.INI and change netcard=am2100.dos to netcard=pcntnd.dos under section [network drivers]
  13. Change all occurrences of ms$am2100 to ms$AMD_PCNet and remove ; INTERRUPT=9, ; IOADDRESS=0x300 and ; DMACHANNEL=5 from the originally named [ms$am2100] section in PROTOCOL.INI
  14. You can customise IP and DHCP configuration under section [TCPIP] in PROTOCOL.INI
  15. Reboot and networking should be working
  16. You can map shares using the command net use d: \\computername\sharename

My Setup
VMware Server v2.0.2 running under Ubuntu 8.04.4 LTS
MS DOS v6.22