Thomas Bork
2003-Jan-30 00:24 UTC
[Samba] not enough charcters available in %J or confusing blanks?
Hi, I try to create PDF files with an modified script from Buchan Milne and have some problems with the Jobname var %J. Because it is better for the users to find an file with an similar name as the original document I'm looking for a way to read out %J, cut some unnessasary stuff and use the rest as new file name. The problem is: In %J in some circumstances is not the complete Jobname as some Windows Applications (example: Ultraedit) send it: 1. (completely failed): Jobname in Windows: "C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\Neu Textdatei.txt" Jobname in %J: "C:\Dokumente und Einstellungen\" [2003/01/30 01:05:12, 3] printing/print_generic.c:print_run_command(88) Running the command `( /pdfcreate.sh smbprn.000175.ChIgbF ~root \\\\linux\\root tb2 192.168.0.7 "C:\Dokumente und Einstellungen\" ) &' gave 2 2.(okay): Jobname in Windows: "C:\Programme\Neu Textdatei.txt" Jobname in %J: "C:\Programme\Neu Textdatei.txt" [2003/01/30 01:17:01, 3] printing/print_generic.c:print_run_command(88) Running the command `( /pdfcreate.sh smbprn.000183.SokUlg ~root \\\\linux\\root tb2 192.168.0.7 "C:\Programme\Neu Textdatei.txt" ) &' gave 0 3. (failed): Jobname in Windows: C:\Programme\Ghostscript\gs7.04\examples\Neu Textdatei.txt Jobname in %J: "C:\Programme\Ghostscript\gs7.04" [2003/01/30 01:19:00, 3] printing/print_generic.c:print_run_command(88) Running the command `( /pdfcreate.sh smbprn.000187.CH3mll ~root \\\\linux\\root tb2 192.168.0.7 "C:\Programme\Ghostscript\gs7.04" ) &' gave 0 4. (failed): Jobname in Windows: C:\Neuer Ordner mit Leerzeichen\Neu Textdatei.txt Jobname in %J: "C:\Neuer Ordner mit Leerzeichen" [2003/01/30 01:26:06, 3] printing/print_generic.c:print_run_command(88) Running the command `( /pdfcreate.sh smbprn.000191.AoaS4Y ~root \\\\linux\\root tb2 192.168.0.7 "C:\Neuer Ordner mit Leerzeichen" ) &' gave 0 Is there a way to store th correct Jobname in %J? Only this way it is possible to filter out the document name for new PDF file. Here is the script for pdf printing with some debugging stuff: #!/bin/sh #---------------------------------------------------------------------- ------ # /usr/local/bin/samba-print-pdf - print to a pdf-file # # Copyright (c) 2001-2003 Thomas Bork <tom@fli4l.de> # # Creation: 23.07.2002 Buchan Milne # Last Update: 29.01.2003 tb # # Arguments: # $1 = file (usually passed with %s from samba) # $2 = unix prefix to where to place the file (~%u should work) # $3 = windows prefix to the same location (\\%L\%u should work) # $4 = user/computer to send a notification to (%u or %m) # $5 = IP address of client (%I) # $6 = Name of Job (%J) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------- ------ info0=/var/tmp/info0-$$.log PS2PDF=ps2pdf13 OPTIONS="-dAutoFilterColorImages=false -sColorImageFilter=FlateEncode" INPUT=$1 echo "Input is $INPUT" >$info0 KEEP_PS=0 PERMS=640 INFILE=$(basename $INPUT) echo "Infile is $INFILE" >>$info0 BASEFILE=pdf-service echo "Basefile is $BASEFILE" >>$info0 PREFIX="$2" echo "Prefix is $PREFIX" >>$info0 ORGNAME="$6" echo "Orgname is $ORGNAME" >>$info0 NAME="$6" echo "Name is now $NAME" >>$info0 NAME=`echo $NAME | sed 's#\\\\#/#g' | sed 's/ //g' | sed 's/\.[^\.]*$//'` echo "name is now $NAME" >>$info0 NAME=`basename "$NAME"` echo "name is now $NAME" >>$info0 WINBASE=$(echo "$3"|sed -e 's,/,\\\\,g') if [ "$1" == "status" ] then echo "Printer: PDF-generator bogus status" echo "Queue: no printable jobs in queue" echo "Server: no server active" echo "Filter_status: done" echo "Rank Owner/ID Class Job Files Size Time" exit 0 fi OUTPUT="$2/$BASEFILE-$4-$$"> $OUTPUTif [ $? -ne 0 ] then echo "Can't create temp file $OUTPUT, exiting..." >$info0 else if [ "$NAME" != "" ] then FINALOUTPUT="$PREFIX/$NAME" else FINALOUTPUT="$OUTPUT" fi WIN_OUTPUT="$WINBASE\\"`basename "$FINALOUTPUT"` $PS2PDF $OPTIONS $INPUT $OUTPUT.pdf >/dev/null 2>&1 mv -f "$OUTPUT".pdf "$FINALOUTPUT".pdf (echo "Hi," echo "your file with original name" echo "$ORGNAME" echo "was converted. You will find it here:" echo "" echo "$WIN_OUTPUT.pdf" ) >>$info0 if [ "$KEEP_PS" = "1" ] then mv -f $INPUT "${FINALOUTPUT}".ps (echo "" echo "Your postscript file is here:" echo "$WIN_OUTPUT.ps" ) >>$info0 chmod $PERMS "${FINALOUTPUT}".ps else rm -f $INPUT chmod $PERMS "${FINALOUTPUT}".pdf fi rm -f $OUTPUT fi smbclient -U "eisfair pdf-service" -M "$4" -I "$5" 1> /dev/null <$info0 rm -f $info0 Here is the printer share for the virtuell printer in smb.conf: [pdf] comment = pdf-service on %h use client driver = yes browseable = yes printable = yes path = /tmp lpq command = /usr/local/bin/samba-print-pdf status print command = ( /pdfcreate.sh %s ~%u \\\\%L\\%u %m %I "%J" ) & public = yes create mode = 0700 der tom
Thomas Bork
2003-Feb-19 13:46 UTC
[Samba] not enough charcters available in %J or confusing blanks?
Hi, I try to create PDF files with an modified script from Buchan Milne and have some problems with the Jobname var %J. Because it is better for the users to find an file with an similar name as the original document I'm looking for a way to read out %J, cut some unnessasary stuff and use the rest as new file name. The problem is: In %J in some circumstances is not the complete Jobname as some Windows Applications (example: Ultraedit) send it: 1. (completely failed): Jobname in Windows: "C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\Neu Textdatei.txt" Jobname in %J: "C:\Dokumente und Einstellungen\" [2003/01/30 01:05:12, 3] printing/print_generic.c:print_run_command(88) Running the command `( /pdfcreate.sh smbprn.000175.ChIgbF ~root \\\\linux\\root tb2 192.168.0.7 "C:\Dokumente und Einstellungen\" ) &' gave 2 2.(okay): Jobname in Windows: "C:\Programme\Neu Textdatei.txt" Jobname in %J: "C:\Programme\Neu Textdatei.txt" [2003/01/30 01:17:01, 3] printing/print_generic.c:print_run_command(88) Running the command `( /pdfcreate.sh smbprn.000183.SokUlg ~root \\\\linux\\root tb2 192.168.0.7 "C:\Programme\Neu Textdatei.txt" ) &' gave 0 3. (failed): Jobname in Windows: C:\Programme\Ghostscript\gs7.04\examples\Neu Textdatei.txt Jobname in %J: "C:\Programme\Ghostscript\gs7.04" [2003/01/30 01:19:00, 3] printing/print_generic.c:print_run_command(88) Running the command `( /pdfcreate.sh smbprn.000187.CH3mll ~root \\\\linux\\root tb2 192.168.0.7 "C:\Programme\Ghostscript\gs7.04" ) &' gave 0 4. (failed): Jobname in Windows: C:\Neuer Ordner mit Leerzeichen\Neu Textdatei.txt Jobname in %J: "C:\Neuer Ordner mit Leerzeichen" [2003/01/30 01:26:06, 3] printing/print_generic.c:print_run_command(88) Running the command `( /pdfcreate.sh smbprn.000191.AoaS4Y ~root \\\\linux\\root tb2 192.168.0.7 "C:\Neuer Ordner mit Leerzeichen" ) &' gave 0 Is there a way to store th correct Jobname in %J? Only this way it is possible to filter out the document name for new PDF file. Here is the script for pdf printing with some debugging stuff: #!/bin/sh #---------------------------------------------------------------------- ------ # /usr/local/bin/samba-print-pdf - print to a pdf-file # # Copyright (c) 2001-2003 Thomas Bork <tom@fli4l.de> # # Creation: 23.07.2002 Buchan Milne # Last Update: 29.01.2003 tb # # Arguments: # $1 = file (usually passed with %s from samba) # $2 = unix prefix to where to place the file (~%u should work) # $3 = windows prefix to the same location (\\%L\%u should work) # $4 = user/computer to send a notification to (%u or %m) # $5 = IP address of client (%I) # $6 = Name of Job (%J) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------- ------ info0=/var/tmp/info0-$$.log PS2PDF=ps2pdf13 OPTIONS="-dAutoFilterColorImages=false -sColorImageFilter=FlateEncode" INPUT=$1 echo "Input is $INPUT" >$info0 KEEP_PS=0 PERMS=640 INFILE=$(basename $INPUT) echo "Infile is $INFILE" >>$info0 BASEFILE=pdf-service echo "Basefile is $BASEFILE" >>$info0 PREFIX="$2" echo "Prefix is $PREFIX" >>$info0 ORGNAME="$6" echo "Orgname is $ORGNAME" >>$info0 NAME="$6" echo "Name is now $NAME" >>$info0 NAME=`echo $NAME | sed 's#\\\\#/#g' | sed 's/ //g' | sed 's/\.[^\.]*$//'` echo "name is now $NAME" >>$info0 NAME=`basename "$NAME"` echo "name is now $NAME" >>$info0 WINBASE=$(echo "$3"|sed -e 's,/,\\\\,g') if [ "$1" == "status" ] then echo "Printer: PDF-generator bogus status" echo "Queue: no printable jobs in queue" echo "Server: no server active" echo "Filter_status: done" echo "Rank Owner/ID Class Job Files Size Time" exit 0 fi OUTPUT="$2/$BASEFILE-$4-$$"> $OUTPUTif [ $? -ne 0 ] then echo "Can't create temp file $OUTPUT, exiting..." >$info0 else if [ "$NAME" != "" ] then FINALOUTPUT="$PREFIX/$NAME" else FINALOUTPUT="$OUTPUT" fi WIN_OUTPUT="$WINBASE\\"`basename "$FINALOUTPUT"` $PS2PDF $OPTIONS $INPUT $OUTPUT.pdf >/dev/null 2>&1 mv -f "$OUTPUT".pdf "$FINALOUTPUT".pdf (echo "Hi," echo "your file with original name" echo "$ORGNAME" echo "was converted. You will find it here:" echo "" echo "$WIN_OUTPUT.pdf" ) >>$info0 if [ "$KEEP_PS" = "1" ] then mv -f $INPUT "${FINALOUTPUT}".ps (echo "" echo "Your postscript file is here:" echo "$WIN_OUTPUT.ps" ) >>$info0 chmod $PERMS "${FINALOUTPUT}".ps else rm -f $INPUT chmod $PERMS "${FINALOUTPUT}".pdf fi rm -f $OUTPUT fi smbclient -U "eisfair pdf-service" -M "$4" -I "$5" 1> /dev/null <$info0 rm -f $info0 Here is the printer share for the virtuell printer in smb.conf: [pdf] comment = pdf-service on %h use client driver = yes browseable = yes printable = yes path = /tmp lpq command = /usr/local/bin/samba-print-pdf status print command = ( /pdfcreate.sh %s ~%u \\\\%L\\%u %m %I "%J" ) & public = yes create mode = 0700 der tom