Indiana University
University Information Technology Services
  
What are archived documents?

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:

cat myfile | ansiprt

Replace myfile with the name of the file you want to print.

If you are using a Unix host that does not have the ansiprt 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 ~/bin/ansiprt).

   #!/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 ansiprt script in this manner won't work on Unix systems that do not have Perl installed.

At Indiana University, to get support for personal or departmental Linux or Unix systems, see At IU, how do I get support for Linux or Unix?

Also see:

This is document abye in domain all.
Last modified on August 22, 2008.
Please tell us, did you find the answer to your question?