Printing to Windows Printers

Ancient article only here for historical purposes.

I've had several people write to me not understanding that they need to PASTE THE CODE FROM THIS ARTICLE into "/usr/spool/lp/model/visionp"

NOTE: The 3.1 version of Visionfs has a new method for installing printers. You can still use the method shown here, but the following command adds a new Unix printer called "winprint" and prints to a Windows share called "HP5" on the machine "Win98_17":



/usr/vision/bin/visionfs print --install winprint Win98_17 HP5

 
THIS ONLY WORKS BEGINNING WITH VERSION 3.1

You may still want to use this article (or J.P. Radley's version for the purpose of having more direct control. -Tony

Copyright © 1999 UniTech Informatica Ltda

This is a little contribution to the sco users community. With this script, is possible send print jobs to printers attached to Windows, via lp(C) command using SCO VisionFS.

The script, by default, converts CR to CR+LF to avoid overprinting but, with the -oraw option this feature can be disabled.

I have many clients using this resource with success.

Instructions for installation and configuration are in the beginning of script.

Jose Fernando Scheid Mascarenhas
UniTech Informatica Ltda

==========================================================================>>>
CUT HERE
:
#       @(#) VisionFSp 1.1 99/01/26 
#
#       Copyright (C) 1999 UniTech Informatica Ltda
#                          Jose Fernando Scheid Mascarenhas
#                          SCO Premier Reseller - Brasil
#                          Todos direitos reservados.
#
#       The information in this file is provided for the exclusive use of
#       the licensees of The Santa Cruz Operation, Inc.  Such users have the
#       right to use, modify, and incorporate this code into other products
#       for purposes authorized by the license agreement provided they include
#       this notice and the associated copyright notice with any such product.
#       The information in this file is provided "AS IS" without warranty.
#
#!      VisionFS Printers
#
#       Options: lp -oraw  file-name ...  Send without CR to CR+LF convertion
#
#       This script will redirect the print job to the shared printer
#       specified in the Description field of mkdev lp.
#
#       Ex.:
#
#       mkdev lp
#       
#       Printer ---> Add Local
#       Name: winptr
#       Description:  SHARE=//winstation1/epson
#       Model: visionp
#       Device: /dev/null
#
#       ATTENTION: Change the permission of vfscinfo and vfsprint.
#
#       cd /usr/vision/visionfs/bin/i3sc0325
#       chown root vfscinfo vfsprint
#       chmod u+s vfscinfo vfsprint
#


       

###########
## Check arguments
###########

parse () {
        echo "`expr \"\" : \"^[^=]*=\(.*\)\"`"
}


#Set up some global variables.
: ${SPOOLDIR:=/usr/spool/lp}
: ${LOCALPATH:=${SPOOLDIR}/bin}
: ${COMMENT:=${SPOOLDIR}/admins/lp/printers}

#Set up printer share name in comment file

PNAME=`basename  `
PDEST=`lpstat -p${PNAME} -l | grep "Description"`
PDEST=`expr "${PDEST}" : '.*=\(.*\)'`

#Set up VisionFS location
if [ -x "/usr/vision/bin/visionfs" ]
   then
   VISIONFS="/usr/vision/bin/visionfs"
else
  if [ -x "/usr/local/vision/bin/visionfs" ]
     then
     VISIONFS="/usr/local/vision/bin/visionfs"
  else
     VISIONFS="visionfs"
  fi
fi


#Set up the default filter.
if [  -x "${LOCALPATH}/lp.cat" ]
then
        LPCAT="${LOCALPATH}/lp.cat 0"
else
        LPCAT="cat"
fi

#If we are not using a filter, use the default one.
if [ -z "${FILTER}" ]
then
        FILTER="${LPCAT}"
fi

if [ -x "${LOCALPATH}/drain.output" ]
then
        DRAIN="${LOCALPATH}/drain.output 1"
else
        DRAIN=
fi

printer=`basename  `
request=
name=
title=
copies=
options=
shift; shift; shift; shift; shift

# border around the banner
x="xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz"

banner=no
raw=no

if [ -z "${BANNERS}" ]
then
        nhead=1
else
        nhead=${BANNERS}
fi

for i in $options; do
        case $i in
        b|nobanner)     banner=no
                        ;;

        r|raw)          raw=yes
                        ;;

        esac
done


[ "$banner" = yes ] && {
        # get the local system id
        if test -r /etc/systemid; then
                sysid=`sed 1q /etc/systemid`
        else
                sysid=`uname -n`
        fi

        # user = fifth field of /etc/passwd
        user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$//p" /etc/passwd`

        # nhead gets the value of BANNERS or 1 by default
#       nhead=`sed -n 's/^BANNERS=//p' /etc/default/lpd`
#       [ "$nhead" -ge 0 -a "$nhead" -le 5 ] || nhead=1

        # print the banner $nhead times
        while   [ "$nhead" -gt 0 ]
        do
                echo "$x\n"
                banner "$name"
                echo "$x\n"
                [ "$user" ] && echo "User: $user\n"
                echo "Request id: $request\n"
                echo "Printer: $printer\n"
                date
                echo "\nMachine: $sysid\n"
                [ "$title" ] && banner $title
                echo "\f\c"
                nhead=`expr $nhead - 1`
        done
}

# send the file(s) to the standard out $copies times
while   [ "$copies" -gt 0 ]
do
   for file
   do
    if [ "${raw}" = "yes" ]
       then
       $VISIONFS print $PDEST ${file}
    else
       awk -e '{printf("%s\r\n", );}' < $file | $VISIONFS print $PDEST -
    fi
   done
   copies=`expr $copies - 1`
done

exit 0
==========================================================================>>>
CUT HERE
 

Note: this script needs to be installed as /usr/spool/lp/model/visionp before you can use it. To do this, cut and paste the lines betwwen the "=======>>" lines into that file name (it won't currently exist; you need to create it).

See also /Unixart/jprdiff.html for an HPLaserJet version of this.



Got something to add? Send me email.





Increase ad revenue 50-250% with Ezoic


More Articles by © UniTech Informatica Ltda



Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

privacy policy