Printing to a raw printer using DOSBox
Working article is here: https://gist.github.com/tresf/48183217173cdaef580b2cb1797a052c
Although DOSBox offers printing support, the documentation is sparse and most articles refer to printing on a Windows host.
Using Ubuntu 20.04 and a fork of DOSBox called DOSBox-X, printing can be configured as follows:
Although DOSBox offers printing support, the documentation is sparse and most articles refer to printing on a Windows host.
Using Ubuntu 20.04 and a fork of DOSBox called DOSBox-X, printing can be configured as follows:
- Install DOSBox-X
- Configure DOSBox-X to write to a physical file
- Write a script which listens on the physical file
Install DOSBox-X
- Installing DOSBox-X on Linux is as simple as installing the snap: https://snapcraft.io/dosbox-x. This can be launched with Ubuntu Software center.
Note: For Windows, MacOS or RPM users, DOXBox-X can be downloaded directly from the official site.
Configure DOSBox-X to write to a physical file
Although the recommendation for most tutorials is to configure DOSBox to print to a physical printer, I was unable to get this working on Ubuntu 20.04. Instead, I had to manually configure DOSBox to print to a file.
- Start DOSBox-X for the first time from Terminal
dosbox-x - Save a default configuration file (the default location is your $HOME directory, this is fine)
Write a script which listens on the physical file
Finally, write a bash script which listens on this prnout.txt file.- Create a file called printlistener.sh
gedit printlistener.sh & - Paste the following
#!/bin/bash
# File to look for
TOPRINT=~/prnout.txt
printf "Waiting for content at $TOPRINT\n"
while [ true ]; do
printf "."
sleep 1 # one second
if test -f "$TOPRINT"; then
printf "\n[$(date)] Sending $(wc -c "$TOPRINT" | awk '{print $1}') bytes\n"
lpr -o raw "$TOPRINT" && rm "$TOPRINT"
fi
done - Make it executable:
chmod +x printlistener.sh - Start the listener
./printlistener.sh
Last, print from the DOS application and it will send to your printer. Note, this will send content in a text format. This may be undesirable for certain printers.
For assistance setting up a default raw printer in Linux see here: https://github.com/qzind/tray/wiki/setting-up-a-raw-printer-in-ubuntu-linux
Comments