$PRINTER environment variable in Unix
Jeff White
jeff at drexel.UUCP
Fri Aug 5 00:53:36 AEST 1988
In article <1988Aug2.085719.11489 at gpu.utcs.toronto.edu>, romwa at gpu.utcs.toronto.edu (Mark Dornfeld) writes:
> Is there a "standard" method for implementation of a $PRINTER
> environment variable in a user's shell? When several printers
> are on a single system, it is usually desirable to have user
> output appear on the printer closest to his/her work area
> instead of on a printer six floors up and on the other side of
> the building.
>
> ...
>
> If anyone has implemented such an environment, please reply via
> Email.
>
I've modified the login program to do exactly that (we run 4.2 BSD and have
source code to it). Basically, I just duplicated all the code in login
that sets up the terminal type, and changed it so it sets a PRINTER variable
instead. It uses a file called /etc/lprtype, the same format as ttytype,
except instead of the terminal type, I just specify the name of a printer. The
nice thing about it is that is is setup automatically (no way to accidentally
or on purpose remove the code from a .login file, for example), and it chooses
the printer based on what terminal you are logged in to, not who you are
logged in as.
Since it is an almost complete duplication of Berkeley code, I'm not sure
if I could legal send out a copy of my updated program, or even the
modifications. Perhaps someone of the legal persuasion could answer this
for me.
Just as an additional note, I also wrote two other modifications which
may be of interest.
The first was the ability to specify priorities to people logging in. Our
computer is primarily for faculty and grad student research, but occasionally
we have 1 or 2 undergrad courses on it, and we wanted to be able to have those
people run at a lower priority. I created a file called /etc/priority which
handles all of it. Part of it is shown below.
# Format of /etc/priority file
# {user,group name}:{u,g}:{priority}:{display code}:{message id}:{type of acc}
# {string}:{string*1}:{int}:{int}:{string}:{string*1}
# display code: -1 (don't show), 0 (user optional), 1 (force display)
# message id is name of file to display, located in /etc/priors
# type of account: r (research), e (educational/class), c (commercial)
uucp:u:1:0::r
nick:u:0:0::r
jeff:u:0:0::r
lisa:u:1:0::r
Y901:g:0:1:y901:e
In login, the code makes two passes over this file. First it checks to see
if the group you belong to is listed (the first field must match and the second
field must be a 'g'). say you belonged to group Y901. The priority file
says that your priority will be set to 0 (unchanged), and that the message file
y901 (in the default directory /etc/priors) will always be displayed (if it
was set to 0 (user optional), a .priority file (or something like that - I
forget the exact name) could be created so that a message would not appear (like
.hushlogin).
A second pass is then made to see if a username match is made. If it is,
these values are used. This was implemented so that, for example, a class
could have it's priority reduced, but the instructor or T/A (also using a
class account), could have his priority set to a higher, more normal priority.
The other modification I made was to have the ability to display a separate,
unique motd for each terminal. I created a directory call /etc/motds, and in
it are the names of the terminals (h1, p0). After /etc/motd is displayed,
login checks to see if a file exists for the terminal, and if it is readable,
displays it. We use it because we have a lot of different terminals (ordinary
vt100's, Qume text and graphics terminals, a Tektronix color terminal, and also
some Mac's), and it allows us to give some information about each terminal.
Some examples are:
----
This is a Tektronix 4105 graphics terminal.
To go into graphics mode, type '4105' (use 'gclear' to clear screen').
To go into editing (text) mode, type 'vt100'.
----
----
If you are using MacTerminal/DU_Talk and plan on doing file transfer
between the Mac and the Vax, make sure that the remote computer is set
up to be a Macintosh and the transfer protocol is Xmodem under the File
Transfer Setting menu (also equivalent to MacTerminal 1.1 and Mac Xmodem).
You should then use the commands macsend and macput on the Vax. As
a quick note, both commands with the '-u' option allow uploading and
downloading of text files.
----
I think this is a really useful feature, especially for anyone is a public
access environment with lots of different equipment. If you have questions
about any of this, feel free to respond.
Jeff White
Drexel University - ECE Dept.
rutgers!bp!drexel!jeff
More information about the Comp.unix.questions
mailing list