Jason,
I am ever so grateful to you for mentioning that the PRINTER
environmental variable controls the "local default" printer assignment. I
just didn' know and it makes my life simpler. I do have a question: if the
printer is not postscript capable, how do I make sure that the output is
pumped throuh ghostscript with the right driver? Normally I just
substitute printer aware script for lpr command (say, "myprinter" instead
of "lpr" in netscape print setup).
On Wed, 5 Jun 2002, Jason Bechtel wrote:
> Daniel,
>
> Absolutely. You can do it by user or workstation. I've
> done this as follows...
>
> First, you have to consider from which apps you will want
> the default printing to work. Most apps acknowledge the
> $PRINTER environment variable. Some, like StarOffice, have
> their own printer system on top of the OS's printer system.
> So, just realize that this might not be your whole
> solution.
>
> Now, all you need to do it get the PRINTER variable set
> when the user logs in. Many different scripts are run when
> a user logs in. Take your pick. I prefer to control
> things at the level of the shell, so (assuming you are
> using Bash) that would imply using .bashrc, .bash_profile,
> or .profile in each user's home directory (man bash if you
> don't know the difference between these files). Or, if you
> don't want to have to deal with all those files, you could
> just do it in /etc/profile or as an added file in
> /etc/profile.d/ (if this directory exists in your
> distribution). Actually, the file in /etc/profile.d/ is
> probably the best bet. It won't get overwritten if you
> upgrade your distribution and it's just a single file. You
> can call it whatever you want, but I'd probably call it
> default_printer.sh.
>
> Now, all you have to do it put a cute little script in
> there to do what you want. It might look something like
> this (off the top of my head, so please test it out in a
> safe place first):
>
> #!/bin/bash
>
> # default_printer.sh
> #
> # Sets PRINTER to an appropriate value based on the
> workstation name.
> #
>
> # file containing assignment of workstations to printers
> DEFPRNS=/etc/default_printers
>
> # root is exempt from this policy
> if [ "$USER" = "root" ]; then
> exit 0
> fi
>
> if [ ! -r "$DEFPRNS" ]; then
> echo "$DEFPRNS is unreadable or does not exist!"
> exit 1
> fi
>
> echo -n "setting default printer..."
> WHERE=`echo $DISPLAY | awk -F: '{print $1}' | awk -F.
> '{print $1}'`
> PRINTER=`cat $DEFPRNS | grep -v "^#" | grep ${WHERE} | head
> -1 | awk -F: '{print $1}'`
> echo " $PRINTER"
>
> # end of default_printer.sh
>
> Now you just need to make the file /etc/default_printers.
> The script makes use of the following file format:
>
> Each important line looks like this:
> printername:<delim>workstation1<delim>workstation2<delim>etc...
>
> Lines that begin with a '#' are ignored, so you can safely
> put comments in the file. Blank lines are also ignored.
> The call to 'head -1' makes it safe against accidentally
> listing a workstation on more than one line. You can make
> the delimeter whatever you want. The only weakness here is
> if you had a workstation whose name is a subset of another
> workstation's name (like ws1 and ws10). You could
> institute a more rigorous format on your printer
> assignments file and avoid this, however. For instance, if
> you choose your delimeter to be a comma and mandate that
> the delimeter must appear before and after each entry, then
> you can modify the grep command to look like this:
>
> grep ",${WHERE},"
>
> and you would then be safe.
>
> Once these steps are done, you can build on $PRINTER for
> special apps like StarOffice... They would require more
> scripting to personlize their printer setups, which should
> be stored in some sort of text file somewhere. I've done
> it for StarOffice, but I don't have the scripts handy right
> now.
>
> If you want to do it on username, just replace $WHERE with
> $USER and put usernames in the /etc/default_printers file.
>
> Jason
>
>
> > From: Daniel =?iso-8859-2?Q?=A3a=B6?=
> <[EMAIL PROTECTED]>
> > Date: 05 Jun 2002 14:51:06 +0200
> > Subject: [Ltsp-discuss] Printing
> >
> > Hi
> >
> > I would like to setup my printing system with LTSP, but I
> want to select
> > default printer for workstation, not for user because
> many users will
> > login to server with the same user account from different
> thin clients.
> > Is it possible ? Where should I start to search any
> HOWTOs and
> > documentations?
> >
> > Daniel Las
>
>
> _______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
>
> _____________________________________________________________________
> Ltsp-discuss mailing list. To un-subscribe, or change prefs, goto:
> https://lists.sourceforge.net/lists/listinfo/ltsp-discuss
> For additional LTSP help, try #ltsp channel on irc.openprojects.net
>
>
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_____________________________________________________________________
Ltsp-discuss mailing list. To un-subscribe, or change prefs, goto:
https://lists.sourceforge.net/lists/listinfo/ltsp-discuss
For additional LTSP help, try #ltsp channel on irc.openprojects.net