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.

I need help with a computing problem

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.



Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

I have a comment for the Knowledge Base

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.