NCR Receipt Printer Script

Just a short script to directly print files to the NCR 7197 Series printers under Linux as there is no direct driver. Certainly not finished or pretty, but functional.

#/bin/sh
###Depends on fmt & iconv for file formatting for printer to operate correctly. Also expects UTF-8 encoded text files.

if [ "$1" == "--help" ];
    then
		echo "NCR 7197 file printing Script"
		echo "Usage:"
		echo "./ReceiptPrinter.sh <FILE> <SERIAL PORT NUMBER>"
		echo "To trim paper off, pass --cut parameter with port number instead of file name."
		echo "This script is currently set up for USB Connection of the printer"
		echo "Make sure your user has access to the serial port you intend to use,"
		echo "otherwise an error will occur"
		echo "This script uses fmt & iconv to format the provided text file for the printer."
		echo "This is 44 characters wide, word wrap enabled & format conversion to US English"

	else
		if [ "$1" == "--cut" ];
			then
				echo -e "\x1B\x07\x1D\x56\x41\x06" > /dev/ttyUSB$2
				echo "Scissor Operated"
				exit 0
	else
		if [ ! -z "$1" ];
			then
				cat $1 | fmt -w 44 | iconv -f UTF-8 -t ISO-8859-1//TRANSLIT > /dev/ttyUSB$2
				echo -e "\x1D\x56\x41\x06" > /dev/ttyUSB$2
				echo "Print Complete"
				exit 0
			else
			echo "No File provided!!! Returning to shell!"
			fi	
		fi
	fi
exit 0

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.