Learn how to a build a cloud-first strategyRegister Now


Linux Kiosk Printer Detection & Script modification

Posted on 2006-04-07
Medium Priority
Last Modified: 2010-04-20
I have a situation where I have built a boot-able CD-ROM based on Ubuntu 5.10. The boot-able CD is working great, but I have this one little thing that I think should be possible but just don't know for sure so I thought I would ask you guys.

When booting the CD-ROM, this is what happens:
The CD Boots, Ubuntu does its thing and loads all the gory tech stuff, and it auto logs in as user Ubuntu.
I have modified parts of the Gnome desktop (specifically the sessions StartUp Programs) to run a script called kisok_setup for me when the user loads. I use this kiosk_setup script to build all my generic printers, and to launce the web browser and acrobat reader (this Kiosk is being set up as Print Station for a MFG plant). As I said everything works fine and I have a working model now. When the kiosk_setup is run, it adds:

1 parallel laserjet (hp compatible)
1 USB laserjet (hp & Linux compatible)
3 known network printers (strategically placed in the plant)

right now, I have to make 2 CD's, one where the default printer is parallel the other where the default printer is USB.

So my question is - does anyone know if there is anyway I could check to see if in fact there is a USB or Parallel printer connected to the PC after it boots (during the execution of kiosk_setup) then make that detected printer the default?

For the kiosk_setup script I am using bash, and this is basically all it does for the printers:

# Printers
# Add a parallel laserjet
lpadmin -p ParaLaser -L WebKiosk -E -v parallel:/dev/lp0 -m laserjet.ppd
# Set parallel printer options
lpoptions -p ParaLaser -o media=letter

# Add a usb laserjet (tested with hplj 1012)
lpadmin -p USBLaser -L WebKiosk -E -v usb:/dev/usb/lp0 -m laserjet.ppd
# Set usb printer options
lpoptions -p USBLaser -o media=letter

# Setting the default printer
lpoptions -d ParaLaser

or for the second CD

# Setting the default printer
lpoptions -d USBLaser

Thanks in advance for any suggestions.
Question by:NTNBower
  • 2

Accepted Solution

edkim80 earned 750 total points
ID: 16404811
I would detect the usb printer, and use it if it is there, but if not default to parallel.  I think the system can detect a usb printer, but i'm not sure about parallel.  

to detect the usb, i'd do something like this...

usb=`lsusb -v | grep USBPRINTERSTRING | wc -l`
if [[$usb = "1"]]
lpoptions -d USBLaser
lpoptions -d ParaLaser

Author Comment

ID: 16416635
I was just working on a script to do that same thing before I left work on Friday! I am plannig to set this up for on a few "known to work" low end printers, so I would think this should work most of the time. So I am guessing there is nothing to check for a parallel?


Expert Comment

ID: 16416976
unfortunately, i do not have access to a parallel printer, so maybe someone else can comment on this...
'lpstat' may give you information on what printers are connected?

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 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