[Webinar] Streamline your web hosting managementRegister Today


perl code to get a list of printer name from user's pc

Posted on 2004-10-21
Medium Priority
Last Modified: 2008-03-06
Hi all, I posted this question a few months ago and no one could answer it. I would like to ask again  if anyone know the way to do it now. thanks

I have a Perl applicaiton running on the unix platform. Users can access the application via  ie browser from their laptop or PC (window xp).  The question is: when user clicks a print button in the perl application, is that a way to what printers are installed/available  on user's PC from perl application?  I am a newbie to Perl and unix stuffs, So any help is appreciated. Thanks in advance.

Question by:Luckyperl
  • 2
  • 2
LVL 48

Expert Comment

ID: 12374283
If the user does

File->Print from their browser they can select a printer.

It's not possible to do it via a server side Perl (or any other language) application.
LVL 20

Expert Comment

ID: 12390710
So what you might be able to do is let the user pick a printer from a list of printers that the server knows how to print to and store that selection (via a cookie or a persistent session variable).

What you cannot do, without violating the web browser security model, is include some script code in a web page that retrieves arbitrary information from the user's PC. I think the default printer selection probably falls under this general prohibition. If you and your users were willing to violate the security model, then it'd be fairly simple to have them download and execute a program that would report the printer selection back to your web server.

Author Comment

ID: 12396967
Could you give more specific or example about this?

"include some script code in a web page that retrieves arbitrary information from the user's PC"

LVL 20

Accepted Solution

jmcg earned 1000 total points
ID: 12397296
Suppose you could write some scripting code on a web page that, without asking the user, searched the hard drive for Quicken data files and extracted account information from them, then sent this information back to a place of the web site's choosing. That's the sort of scenario that the browser's security model is intended to prevent. Of course, learning what printer the user has selected as a default does not sound like such a terrible security problem, but it's something that currently lies outside the boundary of things the browser allows scripts to know.
LVL 48

Assisted Solution

Tintin earned 1000 total points
ID: 12397704
My approach would be similar to jmcg's first suggestion.

The first time a user goes to print, they are given a list of printers to send it to.  When they have selected their desired printer, a cookie is set so that they don't need to select the printer again.

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question