Linux Kiosk Printer Detection & Script modification

Posted on 2006-04-07
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
    LVL 8

    Accepted Solution

    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

    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?

    LVL 8

    Expert Comment

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    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…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now