[EMAIL PROTECTED] wrote:
> Afternoon All.
>
> I am thinking about a perl script that will direct printed output to the
> printer closest to the users terminal rather than relying on them to select
> the correct printer.
As a matter of applications programming style, your application should
alter the default, not force a value upon the user. This allows the
user to select another printer if their closest one if fault, printing
a big job, or whatever.
> I am guessing I will need to create a table with printer preferences based
> on ip address of the terminal. (We use fixed ip addresses). My thoughts
> so far are to get the process id of the perl script and then using a
> combination of ps and w get the ip address of the terminal the user is on.
It might be best to use DNS rather than the IP address directly. If the
printers are far apart then you can simply use the DNS LOC attribute to
record the location of the terminals and the printers. The you can
measure the distance between the terminal and the printers and select
the clostest one.
If they are closer together (say in an office block where the closest
printer 3m away might be below you) then use the TXT DNS record:
terminal101 IN A 10.1.2.3
IN TXT "Printer=cc91apsa"
The advantage of using DNS is that the printer for the terminal
is configured when the terminal is installed, and using a mechanism
the installers can control; a database hidden in an application
wouldn't be nearly so easy to maintain.
The correct way to find the controlling terminal is to use ttyname().
It takes a file descriptor as an argument, fileno(stdin) is probably
suitable.
Use getutent() to turn the terminal name to an IP address.
--
Glen Turner Network Engineer
(08) 8303 3936 Australian Academic and Research Network
[EMAIL PROTECTED] http://www.aarnet.edu.au/
--
The revolution will not be televised, it will be digitised
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug