[Samba] Samba print command only works on restart, help!

Richard rhw at shspost.co.uk
Wed Mar 19 14:38:44 GMT 2003


I am running Samba 2.2.8 on FreeBSD4.8, and all is working well, except:

I have set up a virtual printer using Samba to take a print job, turn it
into a pdf and then email it back to an address, using a perl script and the
Samba print command. I have tested the script logging in as the Samba guest
user and it works fine, but when i try to print to the printer it never
works: the script is called, and gets as far as: Variables Set (see script
below), but the pdf file is never generated. The spool IS cleared however.

After much head scratching i restarted the smbd daemon, and suddenly it
worked. Why? Now, every time i boot the machine i get the same problem:
initially the virtual printer will not generate the pdf file, but will clear
the spool, and after restarting smbd everything works as it should. Can
anyone help?


 workgroup = GROUP
 server string = FreeBSD TestBox
 security = SHARE
 encrypt passwords = Yes
 log file = /var/log/samba_log.%m
 max log size = 50
 guest account = pcguest

 comment = Temporary file space
 path = /tmp
 read only = No
 guest only = Yes
 guest ok = Yes

[PDF Printer]
 comment = prints to PDF file
 path = /var/spool/samba
 guest ok = Yes
 printable = Yes
 printing = sysv
 print command = /usr/bin/printnew.pl %s %s> /tmp/log
 lpq command =
 lprm command =



use Mail::Sender;

my $print_location = '/var/spool/samba/'.shift();
my $print_job = shift();
my $ps2pdf_location = '/usr/local/bin/ps2pdf';
my $output_location = '/var/spool/samba/perl-output.pdf';
my $smtp_server = '';
my $msg_subject = 'subject';
my $msg_body = 'This is a pdf attachment.';
my $from_address = 'whatever at blah.com';
my $auth_user = 'user';
my $auth_pass = 'pass';

my $to_address = 'whatever at blah.com';

print "Variables set.\n";

@ps2pdfcmd = ($ps2pdf_location, $print_location, $output_location);
system(@ps2pdfcmd) == 0
 or die "system @ps2pdfcmd failed: $?";

print "PDF generated.\n";

$sender = new Mail::Sender
  { smtp => $smtp_server, from => $from_address };
if ($sender->MailFile({ to => $to_address,
  subject => $print_job,
  msg => $msg_body,
  file => $output_location,
  auth => 'LOGIN',
  authid => $auth_user,
  authpwd => $auth_pass
}) < 0) {
  die "$Mail::Sender::Error\n";
print "Mail sent to $to_address successfully.\n";

@rmcmd = ("rm", $print_location, $output_location);
system(@rmcmd) == 0
 or die "system @rmcmd failed: $?";

print "Spool cleared.\n";

More information about the samba mailing list