0

I installed a samba service on my raspberry pi 3 linux: Jessie (Debian 8).

smb.conf

[global]
  netbios name = medicalexporter
  workgroup = WORKGROUP

  public = yes

  # Run a WINS server
  wins support = yes

  local master = yes
  preferred master = yes
  os level = 65

  log level = 10
  log file = /home/pi/logs/samba.log.%m

[SambaTest]
  comment = Samba-Test-Freigabe
  path = /home/pi/shares/test
  read only = no

[pdfCreatorLinux]
  path = /tmp
  printable = yes
  guest ok = yes
  print command = /usr/bin/printpdf %s
  lpq command =
  lprm command =

/usr/bin/printpdf

#!/bin/sh
LOG_FILE=/home/pi/logs/pdf.log
exec 3>&1 1>>${LOG_FILE} 2>&1
DATE="date +%b%d-%H%M%S"
OUTDIR=/home/pi/shr/pdfdropbox

"hello" >> /home/pi/logs/2.log
ps2pdf $1 \$OUTDIR/\$DATE.temp
mv \$OUTDIR/\$DATE.temp \$OUTDIR/\$DATE.pdf
rm \$1

For testing purposes I gave this script the permission 777 with sudo chmod 777 /usr/bin/printpdf

samba folder

mkdir -p ~/shr/pdfdropbox
chown root:root ~/shr/pdfdropbox
chmod u+rwx ~/shr/pdfdropbox

The samba service has a user and smbd & nmbd are running. I can see the samba service on my mac under sharing and access the sharing folder. I see the printer under my network printers. When I print a document via the samba printer, it shows me that it is connecting, sending the data and that the data is received without failure.

But the /usr/bin/printpdf seems not to be executed. There is nothing in the /home/pi/logs besides the logs from samba itself (two logs, one with the name of my computer and one with an ip).

When I start the pdf script manually the logs get created.

PS: I mostly sticked to that tutorial: http://www.tldp.org/LDP/LG/issue72/bright.html

Question

Why is the script not executed?

0

I believe this line has an error:

"hello" >> /home/pi/logs/2.log

You may want to try

echo "hello" >> /home/pi/logs/2.log

And you are quoting the $s in the rest of script. I would try to remove the \s. And quote the full file names.

Ending up with:

echo "hello" >> /home/pi/logs/2.log
ps2pdf "$1" "$OUTDIR/$DATE.temp"
mv "$OUTDIR/$DATE.temp" "$OUTDIR/$DATE.pdf"
rm "$1"

in the second half of your script

  • You are right, it does not add the "hello" but the file ist still created empty when the script runs successfully. So this is not the reason the script is not executed. – Andi Giga Jun 23 '16 at 6:53
0

So I found multiple things. First I needed to add printing = BSD maybe otherwise CUPS is used which overrides settings. Then I needed to set printcap name = /dev/null otherwise the ghostscript files disappeared before I could access them. The lpq and lpr commands where not required.

[pdfCreatorLinux2]
#  load printers = no
  printcap name = /dev/null
  path = /tmp/
  printable = yes
  printing = BSD
  print command = /usr/bin/printpdf %s
#  lpq command =
#  lprm command =

Secondly all scripts and folders must be accessible to the user of the samba service.

PS: I also adjusted the pdf script, but this was not the reason why it was not executed.

#!/bin/sh
LOG_FILE=/home/pi/logs/pdf.log
exec 3>&1 1>${LOG_FILE} 2>>&1
DATE=$(date +"%m_%d_%Y")
OUTDIR="/home/pi/shr/pdfdropbox"

ps2pdf $1 "$OUTDIR/$DATE.temp"
mv $OUTDIR/$DATE.temp $OUTDIR/$DATE.pdf
rm $1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.