From owner-freebsd-questions@FreeBSD.ORG Wed Jun 1 02:11:14 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7CBCC16A41C for ; Wed, 1 Jun 2005 02:11:14 +0000 (GMT) (envelope-from on@cs.ait.ac.th) Received: from mail.cs.ait.ac.th (mail.cs.ait.ac.th [192.41.170.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 886D743D55 for ; Wed, 1 Jun 2005 02:11:13 +0000 (GMT) (envelope-from on@cs.ait.ac.th) Received: from banyan.cs.ait.ac.th (banyan.cs.ait.ac.th [192.41.170.5]) by mail.cs.ait.ac.th (8.12.11/8.12.11) with ESMTP id j512B89x067866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 1 Jun 2005 09:11:08 +0700 (ICT) Received: (from on@localhost) by banyan.cs.ait.ac.th (8.13.1/8.12.11) id j512B7uT073953; Wed, 1 Jun 2005 09:11:07 +0700 (ICT) Date: Wed, 1 Jun 2005 09:11:07 +0700 (ICT) Message-Id: <200506010211.j512B7uT073953@banyan.cs.ait.ac.th> From: Olivier Nicole To: roldanlg@yahoo.es In-reply-to: <20050601010854.234.qmail@web25605.mail.ukl.yahoo.com> (message from =?iso-8859-1?q?Rold=E1n?= on Wed, 1 Jun 2005 03:08:54 +0200 (CEST)) References: <20050601010854.234.qmail@web25605.mail.ukl.yahoo.com> X-Virus-Scanned: on CSIM by amavisd-milter (http://www.amavis.org/) Cc: freebsd-questions@freebsd.org Subject: Re: printing X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2005 02:11:14 -0000 > > > how can i print a document in a windows shared > > > > I do that using samba, only samba client is needed. > > > > Olivier > > > can you explaime how? 0) I installed samba from the ports /usr/ports/net/samba 1) I have a shared printer on my windows machine, the printer share is named APPLE, as I use win2k, the printer is accessible to the user "printer", the win2k machine name is "olivier". I set-up a password to protect my win2k printer. For win98, it would be the same, but there is not user. 2) I create an entry in /etc/printcap, the entry is like: # printers attached to users machine (Windows) on-printer:\ :sd=/var/spool/on-printer:\ :mx=0:rs:sh:\ :lp=/dev/null:\ :if=/usr/spool/smb-printer: 3) I create the directory /var/spool/on-printer 4) I create the configuration file /var/spool/on-printer/.config that contains (please put the password as defined in 1): server = olivier service = APPLE password = ******* user = printer domain = olivier Note that server and domain are the same! 5) I installed the script /usr/spool/smb-printer. This script works for win98 and win2k. It does a little bit of file coding, changing CR into CRLF for the files that are not PostScript or PCL. #!/usr/bin/perl require "flush.pl"; ## $logfile="smb-print.log"; ## # or $logfile=/dev/null; $logfile="/dev/null"; ## ## open LOG, ">>$logfile"; ## print LOG `/bin/ls -a`; ## for ($i=0; $i<=$#ARGV; $i++) { ## print LOG "$ARGV[$i]\n"; ## } $loggererr="/usr/bin/logger -i -t print_quota -p lpr.err"; $loggerinfo="/usr/bin/logger -i -t print_quota -p lpr.info"; $mess="SMB print job: -wd ".`pwd`; for ($i=0; $i<=$#ARGV; $i++) { $mess.="$ARGV[$i] "; } # read the config file # the config file should consist of: # # server=servername # service=printername # password=something (be omitted if empty) # open IN, ".config"; $password=""; while () { chop; s/\s*//g; @t=split /=/; $ar{$t[0]}=$t[1]; } close IN; #print LOG `ps auwx|grep perl`; # read standard input and try to guess if we have a PCL or PostScript file # or just plain text # in case of plain text, we should translate CR-> CR/LF # and add a ctrl-l at the end # open IN, "-"; $l=; $t=0; $t=1 unless $l=~/^(\\%.*\@PJL)|(%!PS)/; $l=~s/([^\r])?\n/$1\r\n/g if $t; #print LOG "$t\n"; $command="|/usr/local/bin/smbclient \"//$ar{'server'}/$ar{'service'}\" "; if (exists $ar{user}) { # we are in Win NT world $command.="-U \"$ar{'user'}\%$ar{'password'}\" -W \"$ar{'domain'}\""; } else { # we are in win 9x world $command.="\"$ar{'password'}\""; } $command.=" -N >>$logfile"; #$command.=" -N -P >>$logfile"; # hide the user and password for the LOG $obf=$command; $obf=~s/[\w]+%[\w]+/****%****/; $mess.="$obf"; open SMB, "$command"; print SMB "print -\n"; print SMB $l; while () { s/([^\r])?\n/$1\r\n/g if $t; print SMB $_; $last=$_; } print SMB " " if $t && $last!~/ \r\n$/; close IN; flush(SMB); close SMB; system "$loggerinfo \'$mess\'";