Indiana University
University Information Technology Services
  
What are archived documents?
Login>>
Login

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.

Close

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, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?

This is document abye in domain all.
Last modified on August 22, 2008.

Comments/Questions/Corrections

Use this form to offer suggestions, corrections, and additions to the Knowledge Base. We welcome your input!

If you are affiliated with Indiana University and would like assistance with a specific computing problem, please use the Ask a Consultant form, or contact your campus Support Center.

Contact Information

Note: We will reply to your comment at this address. If your message concerns a problem receiving email, please enter an alternate email address.