[cups] driver configuration

HATEM HATEM hatemgri at hotmail.fr
Wed Sep 5 05:39:16 PDT 2018


hello,

thx for your message. I'm not very expert in printing processes but I can say : the system is very very old and  all printers in HP UX are having the same config/script file ... the only difference is the IP address (PERIPH=XXX.XXX.XXX.XXX):

#!/usr/bin/sh

# (c) Copyright 1992, 1993, 1994 Hewlett-Packard Company.  All Rights Reserved.

# $Header: /users/hpnp/odyssey/repository/sh/hpnp.model.psh,v 1.16 1998/04/29 10:58:14 hpnp Exp $
#
# HP JetAdmin Utility for Unix, HP-UX Network Printer Control Script
#
# This script invokes the original model script from the
# subdirectory model.orig and pipes its output to hpnpf.

if echo $PATH | grep "/usr/bin" > /dev/null 2>&1
then
  :
else
  PATH=$PATH:/usr/bin
  export PATH
fi

# Add bin to the path for systems with /bin
if [ -d /bin ]
then
  PATH=$PATH:/bin
fi

HPNP=/opt/hpnp

# [ Modified by Amit R. Raval to handle the remote printing capability on June
# 24th 1998.

    BIN=/usr/bin

# ]

MODEL=`basename $0`
REALMODEL=`echo $0 | sed -e "s%$MODEL%model.orig/$MODEL%"`

HPNPBIN=$HPNP/bin

TMP=/var/tmp

# [ Modify by the Amit R. to solve the problem of security on 20th Feb. 1998

ID=/usr/bin/id
CUT=/usr/bin/cut
AWK=/usr/bin/awk

         MKDIR=/usr/bin/mkdir

USERNAME=`$ID | $CUT -f1 -d" " | $CUT -f2 -d"(" | $CUT -f1 -d")"` # get user name

if [ $USERNAME = "root" -o $USERNAME = "lp" ]
then
   TMP=$HPNP/tmp
else

   /usr/bin/sun > /dev/null 2>&1
   if [ $? -eq 0 ]
   then
   HOME=`$AWK  'BEGIN   { FS=":" }
         {if ( $1 == UNAME) print $6 ; }' UNAME=$USERNAME /etc/passwd`   # get home dir. from /etc/passwd
   else
   HOME=`$AWK -v UNAME=$USERNAME 'BEGIN   { FS=":" }
         {if ( $1 == UNAME) print $6 ; }' /etc/passwd`   # get home dir. from /etc/passwd
   fi

   if [ ! -d $HOME/.jetadmin ]
   then
      $MKDIR $HOME/.jetadmin > /dev/null 2>&1
      if [ $? -eq 0 ]
      then
        TMP=$HOME/.jetadmin
      fi
   else
        TMP=$HOME/.jetadmin
   fi

fi


# ]

rm -f $TMP/hpnp.$$

LOG=$TMP/hpnp.$$
HPNPF=$HPNPBIN/hpnpf
LPLOG=/var/adm/lp/log
HPNPFLOG=""
debugf=""

PRINTERCFG=/opt/hpnp/admin/printers/7.cfg
JRECOV="yes"
SLEEPSEC=20

LOGTRIES=1
ERRORLOGS=0

MANPATH=$MANPATH:/usr/lib/hpnp/man:/opt/hpnp/man
export MANPATH

# xPORT, PERIPH, TEOJ are all configurable
xPORT=
PERIPH=XXX.XXX.XXX.XXX
DEVTYPE=""
TEOJ=""
STATUSLOG="/opt/hpnp/tmp/cuipclapr1.log"
HPNPFOPT=
TOJMON=""
ONUSTATUS=""

# job monitor related
jobm="no"
userjobm="yes"
jstay=""
defdsplay="`uname -n`:0"
dsplay=""
dsplayfile="$HPNP/etc/hpnpdisplay"
XJETMON=$HPNPBIN/xjjm
topazopt=""

if test ! -w $LPLOG
then
  LPLOG=/dev/null
fi
if [ -z "$PERIPH" ]
then
  PERIPH=$MODEL
fi

job=$1
user=$2
title=$3
copy=$4
options=$5
shift; shift; shift; shift; shift
files="$*"

# changed the parsing of the x hostname from filename to fix defect #43080
# the value of dsplhost is set to be the end of
# the filename.  the file name is of the form (dir)/dA1208(job#)(hostname)
# so the name of the host sending the job is whatever follows the job id
# in the file name
#
file1="$1"
jobnum=`echo $job |  sed "s/.*-//`
dsplhost=`basename $file1  | sed "s/.*$jobnum//"`

PAGEF=$TMP/pg.${job}
rm -f $TMP/pg.${job}
#
# Remove the log file if job is cancelled
# or the scheduler is shutdown.
#
trap "rm -f $LOG $PAGEF;trap 15;kill -15 0;exit 0" 15

# [ Modified by Amit R. Raval to handle the remote printing capability on June
# 24th 1998.

# Handle the options of lpr
remote_lpr()
{

      if [ -n "$options" ]
      then
         for i in $options
         do
             case "$i" in
                   -oBSDJ*) # Handle the "-J" option.
                        title="`echo "$i" | $BIN/sed 's/-oBSDJ//'`";;

                   -oBSDC*)  # Handle the "-C" option.
                        tmpopts="`echo "$i" | $BIN/sed 's/-oBSDC//'`" # strip off -oBSDC
                        if [ "$tmpopts" != "$syst" ]
                        then
                            opts=$tmpopts
                        fi ;;

                   -oBSD*) # Handle other options.
                        ;;

                        *)
                        if [ "$opts" != "" ] # Avoid space in options variable.
                        then
                            opts="$opts $i" # get rest of options
                        else
                            opts="$i"
                        fi;;
              esac
         done

      fi

      options="$opts"

}

# ]

# [ Modified by Amit R. Raval to handle the remote printing capability on June
# 24th 1998.

echo "$options" | $BIN/grep  "\-oBSD" > /dev/null 2>&1

if [ $? -eq 0 ]
then
  remote_lpr
fi

# ]

# search for options
for i in $options
do
  case "$i" in
  # job, jobnp, jobp for bring job up if default is no
    job+[a-zA-Z0-9_:.]*)
      dsplay="`echo "$i" | sed 's/job+//'`"
      jobm="yes";;
    job)
      jobm="yes";;
    jobnp)
      jobm="yes"
      jstay="-nopersist";;
    jobnp+[a-zA-Z0-9_:.]*)
      jobm="yes"
      jstay="-nopersist"
      dsplay="`echo "$i" | sed 's/jobnp+//'`";;
  # following two keep job monitor permanently
    jobp+[a-zA-Z0-9_:.]*)
      dsplay="`echo "$i" | sed 's/jobp+//'`"
      jobm="yes"
      jstay="-persist";;
    jobp)
      jstay="-persist"
      jobm="yes";;
    # nojob prevent job comes up if default is up
    nojob*)
      userjobm="no";;
    debugm[/.a-zA-Z0-9_]*)
      debugf="`echo "$i" | sed 's/^debugm//'`";;
    debugm)
      debugf=$TMP/$MODEL;;
    hpnpflog)
      HPNPFLOG="-l $TMP/hpnpflog"
      rm -f $TMP/hpnpflog
      touch $TMP/hpnpflog
      chmod 666 $TMP/hpnpflog;;
    relay)
      lang="RELAY";;
    topaz)
      if [ $copy -gt 1 ]
      then
        topazopt="-m"
      fi;;
  esac
done

if [ "$debugf" != "" ]
then
  rm -f "$debugf"
  touch $debugf
  chmod 666 $debugf

  if [ ! -w "$debugf" ]
  then
    echo "$debugf is not writable. write to $TMP/$MODEL."  >> $LPLOG
    debugf=$TMP/$MODEL
  fi
  $REALMODEL $job $user "$title" $copy "$options" $files > $debugf
  exit 0
fi

# if PJL device, turn on PJL ;
case "$DEVTYPE" in
  PJL)
    ONUSTATUS="-a1";;
  PJLEX)
    ONUSTATUS="-a3";;
  *)
    if [ "$TEOJ" = "-w" ]  # it should not happen, but double check anyway
    then
      TEOJ=""
      echo "   Non PJL printer, turn off TEOJ" >> $LOG
    fi;;
esac

#Turn off USTATUS and TEOJ if relay mode
if [ "$lang" = "RELAY" ]
then
  ONUSTATUS=""
  TEOJ=""
fi

# bring Job Monitor up
# env. variable DISPLAY does not apply
if $HPNPBIN/psbr
then
  if [ "$jobm" = "yes" -a -x "$XJETMON" ]
  then
    # settle where to display
    if [ "$dsplay" = "" ]
    then
      # get from a file (not tested yet)
      if [ -s "$dsplayfile" ]
      then
        dsplay=`grep "^$user " $dsplayfile | cut -f2 -d" "`
      fi
      if [ "$dsplay" = "" ]
      then      # get display name from job's name

# changed parsing of hostname from filename to fix defect #43080
# the value of dsplhost is set earlier in the script to be the end of
# the filename.  the file name is of the form (dir)/dA1208(job#)(hostname)
# so the name of the host sending the job is whatever follows the job id
# in the file name
#
#        dfname=`basename $opt6`
#        cfname=`dirname $opt6`/c`expr match $dfname '\d\(.*\)'`
#        dsplay="`sed -n "/^H/s/H//p" $cfname`:0"

            if [ -n "$dsplhost" ]
            then
                dsplay="$dsplhost:0"
            fi
        if [ "$dsplay" = "" ]
        then
          dsplay=$defdsplay
        fi
      fi
    fi

    FSIZ=`$HPNPBIN/fsize $files`
    FSIZ=`expr $FSIZ \* $copy`
    if [ -n "$FSIZ" ]
    then
      TOJMON="-b $FSIZ"
    fi
    if [ "$userjobm" = "yes" ]
    then
      echo "\t$XJETMON $dsplay $job &" >> $LOG
      $XJETMON -display "${dsplay}" $jstay $job 2>>$LOG &
    fi
  fi
else
  if [ "$jobm" = "yes" ]
  then
    echo "   hpnpd is not running, no job monitor" >> $LOG
  fi
fi

# pack all options for hpnpf,
HPNPFOPT="-j $job+$user $TEOJ $TOJMON $ONUSTATUS $xPORT -x $PERIPH $HPNPFLOG $topazopt"
if [ -n "$STATUSLOG" ]
then
  rm -f "$STATUSLOG"
  touch "$STATUSLOG"
  chmod 666 "$STATUSLOG"
  HPNPFOPT="$HPNPFOPT -s $STATUSLOG"
fi

echo "\t$REALMODEL $options " >> $LOG
echo "\t$HPNPF $HPNPFOPT" >> $LOG

rm -f $PAGEF

while :
do
  #
  # Save the stderr messages in a temporary log file
  # and discard stdout which is the peripheral output.
  $REALMODEL $job $user "$title" $copy "$options" $files | $HPNPF $HPNPFOPT 2>>$LOG > /dev/null

  retcode=$?

  if [ "$retcode" -eq 0 ]
  then
  #
  # If the transfer is successful (0), remove
  # the log file and exit.
  #
    grep -v Warning $LOG | cat >> $LPLOG
    rm -f $LOG $PAGEF
    exit 0
  else
  #
  # Only record the first $LOGTRIES errors to avoid
  # fill up spooler log
  #

    if [ $retcode -eq 2 -o "$JRECOV" != "yes" ]
    then
      grep -v Warning $LOG | cat >> $LPLOG
      rm -f $LOG $PAGEF
      exit 2
    fi

  #
  #    it is important to check if zero length string, i.e. no options
  #    append to the end of option, so that it won't be overridden
  #    page file exist only for pjl device, as a result, don't do this
  #    if device is not PJL (such as LJ3Si, LJ3,...)

    case "$DEVTYPE" in
      PJL | PJLEX )
        if [ -s $PAGEF ]
        then
          STARTPG=`grep "printed page" $PAGEF | cut -f2 -d: `
# [Modified by Kumaresan on 9th Jan98 to fix the problem of setting
#  srbb option without page number in specific case.
          if [ -z "$STARTPG" ]
          then
# if only one page is printed, "printed page" will not be there in $PAGEF file.
# So, set STARTPG as 1. Otherwise nothing will be set with STARTPG and the srbb
# option will be sent without start page number.
                STARTPG="1"
          fi
# ]

          if [ -z "$options" ]
          then
            options="srbb$STARTPG"
          else
            if [ "$ERRORLOGS" -eq 0 ]
            then     # first recovery
              options=`echo $options | sed -e "s/$options/$options srbb$STARTPG/"`
            else
              options=`echo $options | sed "/srbb/s/srbb[0-9]*/srbb$STARTPG/g"`
            fi
          fi
        fi;;
    esac
        # log it LOGTRIES times
    if test -s $LOG -a $ERRORLOGS -lt $LOGTRIES
    then
      echo "   Unable to finish the job, try to recover job $STARTPG" >> $LOG
    fi
    ERRORLOGS=`expr $ERRORLOGS + 1`
    sleep $SLEEPSEC
  fi
done

________________________________
De : cups <cups-bounces at cups.org> de la part de Tim Mooney <Tim.Mooney at ndsu.edu>
Envoyé : mardi 4 septembre 2018 21:43
À : The CUPS user discussion list.
Objet : Re: [cups] driver configuration

In regard to: [cups] driver configuration, HATEM HATEM said (at 2:28pm on...:

> I tested many drivers (intermec, raw, generic, zebra...), I got
> printing only with raw and generic ones, but text is not formatted as on
> HP Direct Jet. Is there someone who had this experience to help me
> please.
>
> for information on HP Unix, I use a generic driver called "HP CopyJet /
> CopyJetM".

It's been a long time since I've used HP-UX.  Is the HP-UX machine using
traditional System V interface scripts, or is it using something else?  I
don't know if recent HP-UX had CUPS or something else included as its
printing system, so figuring out how job filtering was done would likely
give you a clue where to look on the old systems, to see what the
"drivers" were doing.

A lot of System V interface scripts were just that: scripts.  You could
examine them and see what job control characters were being added to get
the printer to do what you want.

If you can figure out what was being done on the old system, it should
be possible to re-implement that as your own custom filter with CUPS.

Tim
--
Tim Mooney                                             Tim.Mooney at ndsu.edu
Enterprise Computing & Infrastructure                  701-231-1076 (Voice)
Room 242-J6, Quentin Burdick Building                  701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164
_______________________________________________
cups mailing list
cups at cups.org
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.cups.org%2Fmailman%2Flistinfo%2Fcups&data=02%7C01%7C%7C93e88735c35743de162008d6129ee5cd%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636716870992054346&sdata=S5kWzOBhHSe%2FDtGG404%2BOxnmli1uf7JpljKkdixlVqg%3D&reserved=0

________________________________
De : cups <cups-bounces at cups.org> de la part de HATEM HATEM <hatemgri at hotmail.fr>
Envoyé : mercredi 5 septembre 2018 14:36
À : Tim Mooney; The CUPS user discussion list.
Objet : Re: [cups] driver configuration

hello,

thx for your message. I'm not very expert in printing processes but what I can tell you il that all printers in HP UX are having the same config file ... the only difference is the IP address :


________________________________
De : cups <cups-bounces at cups.org> de la part de Tim Mooney <Tim.Mooney at ndsu.edu>
Envoyé : mardi 4 septembre 2018 21:43
À : The CUPS user discussion list.
Objet : Re: [cups] driver configuration

In regard to: [cups] driver configuration, HATEM HATEM said (at 2:28pm on...:

> I tested many drivers (intermec, raw, generic, zebra...), I got
> printing only with raw and generic ones, but text is not formatted as on
> HP Direct Jet. Is there someone who had this experience to help me
> please.
>
> for information on HP Unix, I use a generic driver called "HP CopyJet /
> CopyJetM".

It's been a long time since I've used HP-UX.  Is the HP-UX machine using
traditional System V interface scripts, or is it using something else?  I
don't know if recent HP-UX had CUPS or something else included as its
printing system, so figuring out how job filtering was done would likely
give you a clue where to look on the old systems, to see what the
"drivers" were doing.

A lot of System V interface scripts were just that: scripts.  You could
examine them and see what job control characters were being added to get
the printer to do what you want.

If you can figure out what was being done on the old system, it should
be possible to re-implement that as your own custom filter with CUPS.

Tim
--
Tim Mooney                                             Tim.Mooney at ndsu.edu
Enterprise Computing & Infrastructure                  701-231-1076 (Voice)
Room 242-J6, Quentin Burdick Building                  701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164
_______________________________________________
cups mailing list
cups at cups.org
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.cups.org%2Fmailman%2Flistinfo%2Fcups&data=02%7C01%7C%7C93e88735c35743de162008d6129ee5cd%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636716870992054346&sdata=S5kWzOBhHSe%2FDtGG404%2BOxnmli1uf7JpljKkdixlVqg%3D&reserved=0
_______________________________________________
cups mailing list
cups at cups.org
https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.cups.org%2Fmailman%2Flistinfo%2Fcups&data=02%7C01%7C%7Cb0ff2d4bfc694e3aa90b08d6132c5a69%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717478539579457&sdata=sOnXOc8EwQrsj9chb1Rqy8unV5%2FH%2FmR6Oy2fNTYhSEg%3D&reserved=0


More information about the cups mailing list