On Mon, 24 Sep 2012, Marcin Cieslak wrote:
On Sun, 23 Sep 2012, Jon Trulson wrote:
Looks f'ing stupid to me, but what do I know :) I haven't even looked
at the ancillary dtprint stuff yet. At XiG, I created a 'dtlp' ksh
shell script that worried about the details of a given system's lp
implementation (old-style, LPNG, CUPS, etc) and had dtprintinfo and
friends just use that instead, with well defined options.
Nice. Is your dtlp a different script than that one
included in programs/dtprintegrate/dtlp ?
Yes - it's actually called dtlpc. It is not suitable for primetime
now I would image, but might make a good starting point. I've
attached it in case any one wants to peruse it.
I also noticed that programs/dtprintegrate/dtprintintegrate
script is not used/installed anywhere - it can be used
to add a printer to the "Printers" folder in the "Application
Manager".
Might want to consider something similiar moving forward.
The patches I send to today are needed only to restore basic
sanity to the Print Manager - right now (1) it does not
crash on startup (2) I can see all my CUPS
queues in the Print Manager plus my default printer is
"up and running" (which is not really true, but I digress).
Oh, no prob. There's lots of that to do :)
Yes. I also don't like calling external programs without a full path
- possible security problem if this is ever run as root. Ahem.
Oh yes, I need to add dynamic check whether /usr/bin/lpq (traditional
BSD) or /usr/local/bin/lpq (CUPS) work. Also there seems
to be some demand for the I-have-no-printing-system-installed-at-all
Linux systems.
Didn't check for actual print jobs, removing etc. etc.
but at least someone trying CDE and clicking on the
print icons should get some respone :)
Didn't check drag and drop, printing from file manager
etc. etc.
This is just a basic stuff (should be applicable to Linux
as well).
Yep - thanks for looking at this stuff.
--
Jon Trulson
The Higgs Field is what make atoms matter.
-- Tom L.
#!/bin/ksh
#
#
# For XiG's CDE
#
# dtlpc - try to transparently account (dtprintinfo) for differences
# in lp implementations on various systems (linux traditional vs.
# LPNG).
#
# Jon Trulson, Xi Graphics Inc.
# 4/3/2002
#
# Reorganized and partly rewritten by Michael Piotrowski
# <m...@dynalabs.de>, 2002-11-20
#
# $XiGId: dtlpc,v 1.4 2002/11/23 00:00:25 jon Exp $
#
#####################################################################
CMD="$1" # what we need to do
if [[ -z "$CMD" ]]; then
print "Usage: dtlpc dflt|ga|gqs|gds|startqc|stopqc|startpc|stoppc|listq|lprm
[ARGS]"
exit 1
fi
shift
ARG="$*" # optional args
# Commands understood:
#
# dflt - get the default printer
# ga - get attrs
# gqs - get que stat
# gds - get device status
# startqc - start que cmd
# stopqc - stop que cmd
# startpc - start printing cmd
# stoppc - stop printing cmd
# listq - list queues
# lprm - remove a job from the queue
# Set up a controlled environment
export LANG=C
export PATH=/usr/dt/bin:/usr/bin:/bin:/usr/sbin:/sbin
# Command locations
LPC="/usr/sbin/lpc"
LPADMIN=$(whence lpadmin)
LPSTAT="/usr/bin/lpstat"
ACCEPT="/usr/sbin/accept"
REJECT="/usr/sbin/reject"
ENABLE="/usr/bin/enable"
DISABLE="/usr/bin/disable"
LPRM="/usr/bin/lprm"
# Try to detect the type of print system; currently supported values
# are "sysv", "lprng" and "bsd". Although both CUPS and LPRng provide
# compatibility commands, the native commands are preferable, since
# the compatibility commands don't necessarily provide all options.
# This global variable will contain the print system type
SPOOLER=""
if [[ -n "$LPADMIN" && -x "$LPSTAT" ]]; then
# If lpadmin is available, it's very likely we've got a System
# V-type spooler (on Linux this is probably always CUPS).
SPOOLER="sysv"
elif [[ -x "$LPC" ]]; then
# There are different BSD-flavored print systems floating around.
# This message provides a good comparison of the supported commands
# and options:
#
# http://freestandards.org/pipermail/lsb-spec/2001-February/001323.html
#
# LPRng is even more non-standard, since its commands produce
# output different from the traditional implementations; fortunately
# it can be easily detected: "lpc -V < /dev/null" will produce
# something like this:
#
# LPRng-3.7.4, Copyright 1988-2000 Patrick Powell, <papow...@lprng.com>
#
# Also, some lpc's require an 'all', while others will choke.
STATUS_ALL=""
if [[ $($LPC -V 2>&1 < /dev/null) = LPRng* ]]; then
SPOOLER="lprng"
STATUS_ALL="status all"
else
SPOOLER="bsd"
if [[ $($LPC status all | head -n 1) ]]; then
STATUS_ALL="status all"
fi
fi
else
print "dtlpc: Unknown or defective print system, aborting."
exit 1
fi
# Functions
# All of these functions will return an appropriate exit code:
# 0 - if all ok, 1 if error
# Try to get the default printer.
DOdefault()
{
typeset lpdflt=""
if [[ -n "$LPDEST" ]]; then
lpdflt="$LPDEST"
elif [[ -n "$PRINTER" ]]; then
lpdflt="$PRINTER"
fi
if [[ -z "$lpdflt" ]]; then
case $SPOOLER in
sysv) lpdflt=$($LPSTAT -d | awk '$1 != "no" {print $NF}') ;;
esac
fi
# If we still don't have have a default printer we'll then look at
# the queue list and grab the first one...
if [[ -z "$lpdflt" ]]; then
set -A queues $(DOlistq)
lpdflt=${queues[0]}
fi
print "$lpdflt"
return 0
}
DOga()
{
echo ":::"
return 0
}
# Get queue status: Returns 1 if the queue is disabled.
DOgqs()
{
case $SPOOLER in
sysv) $LPSTAT -a $ARG | awk '/not accepting/ {exit 1}' ;;
lprng) $LPC status $ARG | awk '$3 ~ /disabled/ {exit 1}' ;;
bsd) $LPC status $ARG | awk '/queuing is disabled/ {exit 1}' ;;
esac
return
}
# Get device status: Returns 1 if the device is disabled.
DOgds()
{
case $SPOOLER in
sysv) $LPSTAT -p $ARG | awk '/disabled/ {exit 1}' ;;
lprng) $LPC status $ARG | awk '$2 ~ /disabled/ {exit 1}' ;;
bsd) $LPC status $ARG | awk '/printing is disabled/ {exit 1}' ;;
esac
return
}
DOstartqc()
{
case $SPOOLER in
sysv) $ACCEPT $ARG ;;
lprng|bsd) $LPC start $ARG ;;
esac
return
}
DOstopqc()
{
case $SPOOLER in
sysv) $REJECT $ARG ;;
lprng|bsd) $LPC stop $ARG ;;
esac
return
}
DOstartpc()
{
case $SPOOLER in
sysv) $ENABLE $ARG ;;
lprng|bsd) $LPC enable $ARG ;;
esac
return
}
DOstoppc()
{
case $SPOOLER in
sysv) $DISABLE $ARG ;;
lprng|bsd) $LPC disable $ARG ;;
esac
return
}
DOlistq()
{
case $SPOOLER in
sysv) $LPSTAT -v | awk ' $2 == "for" \
{
x = match($3, /:/);
print substr($3, 1, x-1)
}' | sort
;;
lprng) $LPC $STATUS_ALL | grep -v 'Printer.*Spool.*' |
awk '{print $1;}' | sort
;;
bsd) $LPC status | awk 'NF == 1 \
{
x = match($1, /:/);
print substr($1, 1, x-1);
}' | sort
;;
esac
return
}
DOlprm()
{
# arg will contain a '-P<printer' which is supported by all variants.
$LPRM $ARG
return
}
### MAIN
# redirect stderr to /dev/null
exec 2>/dev/null
# just dispatch depending on the command arg
case $CMD in
dflt)
DOdefault
;;
ga)
DOga
;;
gqs)
DOgqs
;;
gds)
DOgds
;;
startqc)
DOstartqc
;;
stopqc)
DOstopqc
;;
startpc)
DOstartpc
;;
stoppc)
DOstoppc
;;
listq)
DOlistq
;;
lprm)
DOlprm
;;
*)
print "dtlpc: Unrecognized command: $CMD"
exit 1
;;
esac
return
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel