ACCC Home Page ACADEMIC COMPUTING and COMMUNICATIONS CENTER
Accounts / Passwords Email Labs / Classrooms Telecom Network Security Software Computing and Network Services Education / Teaching Getting Help
 
The ADN Connection, November/December 1994 The A3C Connection
Nov/Dec 1994 Contents Moving Learning Online Getting Started with UNIX: Printing What UNIX Shell Are You Using Finding that Newsgroup: on CMS
Finding the Newsgroup: on UNIX More on Mail Expanding Your Disk Space About the ADN Connection  

Getting Started in UNIX: Printing

 
Tech Tip
UNIX Novice
 
   
 
     
Want to Print Something?
 

While UNIX command names tend to be very terse, the UNIX operating system is anything but. Want to print something? The UNIX command apropos lists available UNIX commands by keyword. (As does the equivalent command: man -k )
So what happens when you enter:

apropos print | more
on tigger? It lists 109 commands, all of which have something to do with printing. Whew! Fortunately, it's easier to actually print. Here's a quick guide.

Remember: case matters on UNIX. So enter all commands in the case shown. (Almost everything is in lowercase, so a good rule to go by is always use lowercase unless otherwise specified.)

 
     
Printing a File
  If you're a command line type of person: lpr is a basic UNIX print command:
lpr -P bsb .newsrc
lpr -P grc105 hello.ps
The -P flag allows you to specify a printer. This is a smart idea, because as of now, the default printer on tigger is grc124b, a nonpublic printer in the Computer Center's main office. (But you can select your own default printer; more about that soon.)

.newsrc and hello.ps are the files being printed; lpr can print either plain text or PostScript files, and, in most cases, can even tell the difference. lpr has several other flags; take a look at its man page for more information. In fact, you might want to print a copy:

man lpr | lpr -P bsb
Substitute the name of a convenient printer -- that UNIX knows about (see Listing the Available Printers below) -- for the bsb.

If you're on tigger and you'd rather use a menu: Then use the print command qprt through smit, the AIX "System Management Interface Tool." To submit a print job completely by menu (and to see what smit can do, enter: smit
then select: Spooler (Print Jobs) -> Start a Print Job
Or enter: smit qprt to go directly to the "Start a Print Job" menu. Another way to use qprt is to enter it as a command on the command line, without smit. When used this way, qprt is a full featured print command (that means it has dozens of flags).

The names of the fields in the menu are in a column on the left; the "Entry Fields," where you actually type, are on the right. Use Up or Down to move from field to field. Don't press Enter or Return (except to make a selection from a pop-up window) until you're ready to submit the print job.

You must fill in three fields:

File to print:
This field is highlighted when you enter the menu; type the name of the file to print.
PRINT QUEUE:[Device Queue]
If you want to use a printer other than the default, use Down to move to and highlight this field name, then type the name of a convenient printer.
BURST STATUS:
Highlight this field, then press F4 to display a pop-up window listing the valid entries for the field. Use Down to move to and highlight "header only" on the list; press Enter to select it and close the pop-up window.
Make other changes on the "Start a Print Job" menu if you want; press Enter to submit the print job. Before the submission is complete, you may press F3 to cancel the print job; press F10 to exit.

A nice thing about using qprt through smit is that all you have to remember is three fields that you must enter values for; you don't have to remember how to use the menu. There are instructions on the screen and in each pop-up window, and a table at the bottom of the menu showing the keys that execute the necessary functions. In fact, old CMS hands will find that the screen bears a strong resemblance to their favorite full screen CMS menus.

 
     
Listing the Available Printers
  The basic UNIX command to check printer queues, and, incidentally, to list the names of the printers that the UNIX system knows about, is lpstat. To display the status of all print queues on tigger, enter: lpstat
(The command is a bit different on icarus: lpstat -a )

On tigger, qchk is another one of the 109 commands the apropos command lists for the keyword print. Like qprt, it is available in AIX, but not necessarily in other flavors of UNIX. So, to check the queue of the printers on tigger, enter:

qchk -A
Also like qprt, smit knows about qchk; for a menu interface, enter: smit qchk

Don't think that an empty printer queue necessarily means an idle printer; these UNIX commands only know about UNIX print jobs.

 
     
Selecting a Default Printer
  To select a default printer, set and export the shell variable PRINTER. Enter the following commands at the $ command prompt:
PRINTER=grc105
export PRINTER
This sets the default printer to grc105; any printer listed by lpstat or qchk -A will do.

To have these commands executed each time you login, put them in your .profile file, or in your .env file (introduced in Setting Command Aliases below). Exporting the shell variables allows them to be known in subshells.

 
     
Setting a Command Alias
  Can't remember "qchk?" I can't either. But I can remember the command printers. So here's how to set a command alias in the Korn shell (see "What UNIX shell are you using?") which allows you to enter the command printers in Korn shell and have UNIX actually execute qchk -A.
  1. Create a file in your home directory named .env (or another name of your choice), and in it put the line:

  2. alias printers='qchk -A'
    Put in other aliases if you want; for my account on tigger I also have:
    alias ls='ls -la'
    alias mv='mv -if'
    alias cp='cp -if'
    alias dir='ls -l'
  3. Save .env. Make it executable: chmod u+x .env
  4. Edit your ~/Profile file. Add the following at the bottom, to define, export and execute .env.

  5. ENV=~/.env
    export ENV
    .  $ENV
  6. Save the modified Profile file.
Shell Variables in C Shell:
Shell variables (like $PRINTER and $ENV) are defined slightly differently in C shell. For example, to set and export $PRINTER in csh you'd enter:
PRINTER grc105
setenv PRINTER

In the Korn shell, your Profile is executed each time you login. When you make a change in it like this, you might want to execute it yourself, to make the changes for your current login session. So to set the alias for your current login, enter: . Profile

Note the "period space" at the beginning of this command, and in the last of the three lines you added to your Profile file in Step 2. Yes, it is necessary. The "dot command" tells the shell to run the command as if you has entered the commands yourself at the command prompt. Without it, the command is run in a subshell, and the changes will disappear when the subshell closes.

Want to check whether the alias "took"? In Korn shell, the command: whence cmdname
returns the pathname when cmdname is the name of a script or executable program, or the command executed when it's an alias.

Comments are appreciated; send them to
Judith Grobe Sachs, judygs@uic.edu
 
 

The ADN Connection, Nov/Dec 1994 Previous: Moving Learning Online Next: What UNIX Shell Are You Using


1999-9-2  connect@uic.edu
UIC Home Page Search UIC Pages Contact UIC