In Unix, how do I print a file to my local printer?
In Unix, you can use a utility called
ansiprt in a pipe
to print to your local printer. It wraps its input with the
ANSI media-copy escape codes and spits it back out,
trusting your terminal to behave correctly. You can use
ansiprt to print any text files to your local printer by
entering at the Unix prompt:
myfile with the name of the file you want to
If you are using a Unix host that does not have the
program, you can create a copy from the Perl script that follows.
Save this text to a file named
ansiprt in a directory named
bin in your home directory (so that the full filename is
#!/usr/local/bin/perl # ansiprint - print file/stdin to local printer via ANSI codes # (c)1994 Scott Hutton, Indiana University, UITS Support Center # usage: ansiprint [filename [filename ...]] @input = <>; $lines = @input; warn "Turning on printer...\n"; print "\033[5i", @input, "\033[4i\n"; warn "Turned off printer. Output $lines lines.\n";
Once you've created a copy of the script, be sure to set the file permissions by entering at the Unix prompt:chmod 755 ~/bin/ansiprt
Note: Creating a copy of the
script in this manner won't work on Unix systems that do not have Perl
At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?
Last modified on August 22, 2008.