smbprint, smbclient bug??

Petr Slansky slansky na usa.net
Čtvrtek Říjen 5 18:15:42 CEST 2000


Zdravim,

na serveru se Sambou (2.0.7)  mam nekolik tiskaren (radek, radim, eva, ...).
Tiskarny jsou vzdalene, u pocitacu s W98, tisknu na ne pres "smbprint". Zda
se mi, ze smbclient spatne zobrazuje obsah fronty jednotlivych tiskaren, ze
si je nejak plete, nebo co. Kazda tiskaran ma vlastni spool adresar.
Pozoroval jsem to nejdrive na stanici s W98 (zobrazeni fronty tiskarny).
Pokud kontroluji obsah front pres "lpq -Pjmeno", tak vse je OK. Pokud ale
kontroluji obsah front pres "smbclient \\\\SERVER\\TISKARNA heslo -P -N -c
queue", tak dostavam zmatene odpovedi, nejak samba tiskarny prohazuje,
algoritmus prehazovani jsem neodhalil... Myslim si, ze to je chyba bud
samby, nebo smbclienta... Ulohy nastesti vytiskne spravna tiskarna.
Nastaveni samby pro "lpq dotaz" je "lpq -P%p" v sekci global.

Tady je jeste definice jedne tiskarny v printcap, ostani jsou podobne, jen
se zmeni jmeno. Myslim si, ze pouzivam bsd system tisku (zakladni nastaveni
v Debianu). Jeste zminim, ze mi to "nejak" funguje....

radek:\
 :lp=/dev/null:\
 :sd=/var/spool/lpd/radek:\
 :af=/var/spool/lpd/radek/acct:\
 :lf=/var/spool/lpd/radek.log:\
 :if=/etc/samba/smbprint:\
 :mx#0:\
 :sh:

Taky jsem tady posledne resil problem, s tim, ze mi "smbprint" zahazuje
tiskove ulohy v pripade, ze klient s windows, u ktereho je tiskarna, neni
zapnuty. Uz jsem to nejak osetril, "NEKDY" to funguje. Pisu nekdy, protoze
se stava, ze ulohy je jakoby vytistena a ale ve skutecnosti z tiskarny nic
nevyjde. To bude ale asi chyba windows, nez nabootuji, tak jsou zrejme
zmatene.... V tom pripade mi sice smbclient hlasi nejake chyby, ale bohuzel,
jeho navratovy kod je 0.... Tady je verze "smbprint", ktery ceka na zapnuti
PC s tiskarnou, pracuji s Debianem, takze cesty tomu odpovidaji...

### START smbprint ###
#!/bin/sh

# This script is an input filter for printcap printing on a unix machine. It
# uses the smbclient program to print the file to the specified smb-based
# server and service.
# For example you could have a printcap entry like this
#
# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
#
# which would create a unix printer called "smb" that will print via this
# script. You will need to create the spool directory /usr/spool/smb with
# appropriate permissions and ownerships for your system.

# Set these to the server and service you wish to print to
# In this example I have a WfWg PC called "lapland" that has a printer
# exported called "printer" with no password.

#
# Script further altered by hamiltom na ecnz.co.nz (Michael Hamilton)
# so that the server, service, and password can be read from
# a /usr/var/spool/lpd/PRINTNAME/.config file.
#
# Script further modified by Richard Sharpe to fix some things.
# Get rid of the -x on the first line, and add parameters
#
#    -t  now causes translate to be used when sending files
#
# In order for this to work the /etc/printcap entry must include an
# accounting file (af=...):
#
#   cdcolour:\
# :cm=CD IBM Colorjet on 6th:\
# :sd=/var/spool/lpd/cdcolour:\
# :af=/var/spool/lpd/cdcolour/acct:\
# :if=/usr/local/etc/smbprint:\
# :mx=0:\
# :lp=/dev/null:
#
# The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
#   server=PC_SERVER
#   service=PR_SHARENAME
#   password="password"
#
# E.g.
#   server=PAULS_PC
#   service=CJET_371
#   password=""

#
# Debugging log file, change to /dev/null if you like.
#
#logfile=/tmp/smb-print.log
logfile=/var/spool/lpd/smbprint.log
# logfile=/dev/null


#
# The last parameter to the filter is the accounting file name.
#   Extract the directory name from the file name.
#   Concat this with /.config to get the config file.
#
TRANS=0
eval acct_file=\${$#}
spool_dir=`dirname $acct_file`
config_file=$spool_dir/.config
SMBCLIENT=/usr/bin/smbclient

#echo "config_file: $config_file" >> $logfile

# Should read the following variables set in the config file:
#   server
#   service
#   password
eval `cat $config_file`

#while getopts t c; do
while getopts :t c; do
  case $c in
    t)
       TRANS=1
       ;;
    '?')  # Bad parameters, ignore it ...
       ;;
  esac
done
#
# Some debugging help, change the >> to > if you want to same space.
#
(
echo "$(date)"
echo "$0 $*"
echo "$(id)"
echo "server $server, service $service"
) >> $logfile

while : ; do
  #$SMBCLIENT -L "\\\\$server" $password -N >> $logfile && break
  echo $SMBCLIENT "\\\\$server\\$service" $password -U $server -N -P -c
queue >> $logfile
  $SMBCLIENT "\\\\$server\\$service" $password -U $server -N -P -c queue>>
$logfile && break
  echo "Printer \\\\$server\\$service not ready: SLEEP" >>$logfile
  sleep 10
done

(
echo "$(date)"
echo "PRINT: server $server, service $service"
) >> $logfile

(
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
 if [ $TRANS -eq 1 ]; then
          echo translate
        fi
 echo "print -"
 cat
) | $SMBCLIENT "\\\\$server\\$service" $password -U $server -N -P >>
$logfile
echo "$(date) \\\\$server\\$service exit code: $?">> $logfile
### END smbprint ###


Mate-li nejaky napad co s tim, tak dik...
Petr





Další informace o konferenci Linux