Can anyone suggest a way to have a notification after a print job has completed. I currently have this as my print command: lpr -r -P%p %s; csh -c 'echo \"%J has started printing on %S\" | /usr/bin/smbclient -U %L -M %m -I %I' & It kind of does what I want, but notice that the message says that "Job has STARTED printing on Printer". This is because with this command the message is sent after the lpr command is executed and not when the job is actually done. I would really prefer the message be sent when the job is done, not when it is starting. I saw an old message in the archives suggesting a wrapper for the print command that would keep checking the print queue to see when the job was done and then send the message. This sounds like it would work, but I don't have a clue how to write the wrapper to check the queue. Any help in this matter would be appreciated. Chad Edwards Samba Newbie
I don't do these things but: Look into preexec and postexec commands in smb.conf. Look into your print filter. If it is a simple script, you could just add your smbclient command there, if the Gods of Permissions are smiling. Now, how to tell if the job is successfully printed might take some more effort. You may have to dig into your printing software a bit to find out how to do that. Maybe you could capture an exit code from the command in your print filter that actually sends the file to standard out in your filter. I haven't tried this, but it might work. Or capture the results in your status log. This seems much more involved, though. Joel On Sat, Jun 22, 2002 at 03:31:28PM -0500, Chad Edwards wrote:> Can anyone suggest a way to have a notification after a print job has > completed. I currently have this as my print command: > > lpr -r -P%p %s; csh -c 'echo \"%J has started printing on %S\" | > /usr/bin/smbclient -U %L -M %m -I %I' & > > It kind of does what I want, but notice that the message says that "Job has > STARTED printing on Printer". This is because with this command the message > is sent after the lpr command is executed and not when the job is actually > done. I would really prefer the message be sent when the job is done, not > when it is starting. > > I saw an old message in the archives suggesting a wrapper for the print > command that would keep checking the print queue to see when the job was > done and then send the message. This sounds like it would work, but I don't > have a clue how to write the wrapper to check the queue. > > Any help in this matter would be appreciated. > > Chad Edwards > Samba Newbie > > > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba
Chad Edwards wrote:> lpr -r -P%p %s; csh -c 'echo \"%J has started printing on %S\" | > /usr/bin/smbclient -U %L -M %m -I %I' & > > It kind of does what I want, but notice that the message says that "Job has > STARTED printing on Printer". This is because with this command the message > is sent after the lpr command is executed and not when the job is actually > done. I would really prefer the message be sent when the job is done, not > when it is starting.Just an idea, how about starting a script when you start printing that keeps checking the print que until it's done, then the smbclient thingy? Bas
LPRng has Job Completion Notification via e-mail, if that will do what you need. see: http://www.lprng.com/LPRng-HOWTO/LPRng-HOWTO.html 6.5. Job Completion Notification Requested Jim> -----Original Message----- > From: Chad Edwards [mailto:CEdwards@SkyWeb.ca] > Sent: Saturday, June 22, 2002 1:31 PM > To: samba@lists.samba.org > Subject: [Samba] Print Job Notification > > > Can anyone suggest a way to have a notification after a print job has > completed. I currently have this as my print command: > > lpr -r -P%p %s; csh -c 'echo \"%J has started printing on %S\" | > /usr/bin/smbclient -U %L -M %m -I %I' & > > It kind of does what I want, but notice that the message says > that "Job has > STARTED printing on Printer". This is because with this > command the message > is sent after the lpr command is executed and not when the > job is actually > done. I would really prefer the message be sent when the job > is done, not > when it is starting. > > I saw an old message in the archives suggesting a wrapper for > the print > command that would keep checking the print queue to see when > the job was > done and then send the message. This sounds like it would > work, but I don't > have a clue how to write the wrapper to check the queue. > > Any help in this matter would be appreciated. > > Chad Edwards > Samba Newbie > > > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba >
On Sat, Jun 22, 2002 at 03:31:28PM -0500, Chad Edwards wrote:> Can anyone suggest a way to have a notification after a print job has > completed. I currently have this as my print command: > > lpr -r -P%p %s; csh -c 'echo \"%J has started printing on %S\" | > /usr/bin/smbclient -U %L -M %m -I %I' &As another poster has remarked, it's probably better to get your lpr back end to perform this. Currently Samba doesn't support this, although Samba 3.0 most likely will (i.e I'm probably adding it to CVS as part of a rewrite of the printer change notification system). Tim.
Ok. This is one way to do what you want. I haven't edited this to make it plainer since you ought to do some of this work, too. Basically, just put && Success command || Failure command after your print command in your filter. This filter uses pstotext, which just converts PDP or ps files to plain text and is very good but may not be included with your distribution. It is better than gs. It is out on the internet, somewhere. The print filter below simply takes a postscript, PDP file, or a plain text file and outputs a plain text file to whatever output device is specified in /etc/printcap. In this case, lp=/var/spool/lpd/text/textfile. The printcap that goes with this is: text:\ :sd=/var/spool/lpd/text:\ mx#0:\ :lp=/var/spool/lpd/text/textprint:\ :if=/var/spool/lpd/text/filter:\ :sh: This print filter is designed to enable me to print things off the internet and get a plain text file to include in email. The final text file will wind up in /tmp/textprint. It relies on shell variables which you will see in file junk and shellvalues after the print job is done. Keep in mind that when invoked by lpr, this script will use the file to print as standard input and the destination lp in printcap as standard output. Therefore commands like: set | sed -n "s/^l//p" | xargs file send output to the output device, in this case outfile defined below. And, you have to include the full pathname for programs like mail since the user daemon may not have such programs in its path. Note: This is not a polished product. I am a total amateur. Joel #!/bin/bash cat < /dev/null > junk readfile=/tmp/textprint set > junk outfile=`set | sed -n "s/.*:lp=//p"` echo This is the start >> junk echo This is the outfile $outfile >> junk cat < /dev/null > $outfile set > shellvalues Job=`set | sed -n "s/^N//p"` #============Print Post Script===============a=`set | sed -n "s/^l//p" | xargs file | grep PostScript` echo $a This is a PostScript file > junkname [ -z "$a" ] || { /usr/local/bin/pstotext && echo "Job $Job Done" | /bin/mail -s "PrintingDone" jlh || echo "Job $Job Failed" | /bin/mail -s "Printing Failed" jlh cp -a $outfile $readfile chmod 777 $readfile exit 0 } #===========Print PDF=========================a=`set | sed -n "s/^l//p" | xargs file | grep PDF` echo $a This is a PDF file > junkname [ -z "$a" ] || { # Remember that converting PDF to text requires random # access and so pstotext cannot read the file from std in cat > /tmp/junkprint /usr/local/bin/pstotext /tmp/junkprint -output - && echo "Job $Job Done" | /bin/mail -s "Printing Message" jlh || echo "Job $Job Failed" | /bin/mail -s "Printing Failed" jlh cp -a $outfile $readfile chmod 777 $readfile exit 0 } #============Print Text=======================a=`set | sed -n "s/^l//p" | xargs file | grep text ` [ -z "$a" ] || { cat cp -a $outfile $readfile chmod 777 $readfile exit 0 } #============Bail out====================echo invalid file type of set | sed -n "s/^l//p" | xargs file cp -a $outfile $readfile exit 0 If you wonder at the exit 0 statements, I THINK that the print filter has to exit with status 0, othewise LPRng thinks things have gone bad and will complain. On Sat, Jun 22, 2002 at 03:31:28PM -0500, Chad Edwards wrote:> Can anyone suggest a way to have a notification after a print job has > completed. I currently have this as my print command: > > lpr -r -P%p %s; csh -c 'echo \"%J has started printing on %S\" | > /usr/bin/smbclient -U %L -M %m -I %I' & > > It kind of does what I want, but notice that the message says that "Job has > STARTED printing on Printer". This is because with this command the message > is sent after the lpr command is executed and not when the job is actually > done. I would really prefer the message be sent when the job is done, not > when it is starting. > > I saw an old message in the archives suggesting a wrapper for the print > command that would keep checking the print queue to see when the job was > done and then send the message. This sounds like it would work, but I don't > have a clue how to write the wrapper to check the queue. > > Any help in this matter would be appreciated. > > Chad Edwards > Samba Newbie > > > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba
Opps. Just realized that in the mail notification command, I have only the name of my regular user, jlh. So, change jlh to $User and put this command at the top of the script, right next to Job: User=`set | sed -n "s/^L//p"` You may have to enclose $Job in double quotes, in case there are spaces in the job name. Joel> /usr/local/bin/pstotext && echo "Job $Job Done" | /bin/mail -s "PrintingDone" jlh || echo "Job $Job Failed" | /bin/mail -s "Printing Failed" jlh
Joel, I noticed when copying/pasting script sections, one of the characters fails to be transferred. It's the ` character. For some reason, putty or joe drops the character when pasting. It's hex 0x60, and on my OpenBSD system, I'm using joe as the editor. To insert the character at the current cursor location: Press the `/~ key Press x (for hex) Enter 60 and press Enter Done! I had problems using your lpr command script when I pasted it-turns out the ` was missing in a couple of places, and I had to change the spaces at the start of line to tabs. It all worked after that. I do have one question: what deletes /tmp/junkJ? Do you use a cron job to purge it, or delete it manually? Jim> -----Original Message----- > From: Joel Hammer [mailto:Joel@HammersHome.com] > Sent: Wednesday, June 26, 2002 4:23 AM > To: samba@lists.samba.org > Subject: Re: [Samba] Print Job Notification > > > Opps. Just realized that in the mail notification command, I > have only the > name of my regular user, jlh. So, change jlh to $User and put > this command at > the top of the script, right next to Job: > User=`set | sed -n "s/^L//p"` > You may have to enclose $Job in double quotes, in case there > are spaces > in the job name. > > Joel > > > > /usr/local/bin/pstotext && echo "Job $Job Done" | /bin/mail > -s "PrintingDone" jlh || echo "Job $Job Failed" | /bin/mail > -s "Printing Failed" jlh > > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba >
%J is supposed to contain the banner page for the print job, and this is what is captured by the script. I do not know what you mean by Win2k double spooling. Is the an intrinsic property of win2k or of some particular arrangement you have? Joel On Wed, Jun 26, 2002 at 03:08:06PM -0400, Van Sickler, Jim wrote:> I think it was intended to pull the Windows > file name for the print job out, to pass on to > samba-instead of smbprn.yada.yada > > All mine shows is: > > Remote Downlevel Document hp4plus smbprn.001370.YH8848 > This is truncated Remote Downlevel Document > > because of the way the printers are set up... > win2k double-spools the job, so the filename > info is lost to lprng/samba > > I haven't found the cure for that yet-I may > just delete all of the printers on my Win2k > box, purge the registry, and try again. > I've only done it about 50 times already...;-( > > Jim > > > -----Original Message----- > > From: Joel Hammer [mailto:Joel@HammersHome.com] > > Sent: Wednesday, June 26, 2002 10:36 AM > > To: Van Sickler, Jim; samba@lists.samba.org > > Subject: Re: [Samba] Print Job Notification > > > > > > Is this about notification of printer job done? > > > > The file junkJ was meant more for trouble shooting. Checking just now, > > that file is gone from /tmp, don't know why. /tmp is purged from time > > to time, perhaps by cron. I forget. If you want to keep it for logging > > purposes, you might put it into /var/log and have logrotate > > compress it > > for you. > > > > Joel > > > > > > On Wed, Jun 26, 2002 at 12:07:38PM -0400, Van Sickler, Jim wrote: > > > Joel, > > > > > > I noticed when copying/pasting script sections, > > > one of the characters fails to be transferred. > > > It's the ` character. For some reason, putty > > > or joe drops the character when pasting. > > > > > > It's hex 0x60, and on my OpenBSD system, > > > I'm using joe as the editor. > > > > > > To insert the character at the current > > > cursor location: > > > > > > Press the `/~ key > > > Press x (for hex) > > > Enter 60 and press Enter > > > Done! > > > > > > I had problems using your lpr command script > > > when I pasted it-turns out the ` was missing > > > in a couple of places, and I had to change the > > > spaces at the start of line to tabs. It all > > > worked after that. I do have one question: > > > what deletes /tmp/junkJ? Do you use a cron > > > job to purge it, or delete it manually? > > > > > > Jim > > > > > > > > > > -----Original Message----- > > > > From: Joel Hammer [mailto:Joel@HammersHome.com] > > > > Sent: Wednesday, June 26, 2002 4:23 AM > > > > To: samba@lists.samba.org > > > > Subject: Re: [Samba] Print Job Notification > > > > > > > > > > > > Opps. Just realized that in the mail notification command, I > > > > have only the > > > > name of my regular user, jlh. So, change jlh to $User and put > > > > this command at > > > > the top of the script, right next to Job: > > > > User=`set | sed -n "s/^L//p"` > > > > You may have to enclose $Job in double quotes, in case there > > > > are spaces > > > > in the job name. > > > > > > > > Joel > > > > > > > > > > > > > /usr/local/bin/pstotext && echo "Job $Job Done" | /bin/mail > > > > -s "PrintingDone" jlh || echo "Job $Job Failed" | /bin/mail > > > > -s "Printing Failed" jlh > > > > > > > > -- > > > > To unsubscribe from this list go to the following URL and read the > > > > instructions: http://lists.samba.org/mailman/listinfo/samba > > > > > >
Hi, I think what he means is that Win2k (and WinXP Pro) spools it on what looks like a local print server, then sends it to the real (Samba) server. The application (word, excel, etc) correcly sends the job name to the "server", but that's the Win2k/XP local server. When the job is finally sent to the Samba server, the job name is lost and what's sent to Samba (and put into %J) is "Remote Downlevel Document". I have a notebook with WinXP Home that didn't do this, and my boss has a WinXP Pro which did (and it was not good for our pdf-making scheme ( http://rf.com.br/linux/pdfconv.html )). I've changed this on the WinXP Professional registry (it was the only different thing between my XP Home and his XP Pro) and %J now correctly shows the job/file name. (this applies to Win XP Professional, may be the same for Win2k) On regedit "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" I've removed the "port" pointing to the samba shared printer (yeah, looked strange to me too. On my XP Home it wasn't there, and the "Ports" tab on the samba printer properties shows the printer connected to nothing). I've also tried to change the "serverName", "shortServerName", "uNCName" under the "DsSpooler" entries to point directly to the samba shared printer instead of to the Windows client, and the "printSpooling" from "PrintWhileSpooling" to "PrintDirect". I've returned these to the original settings, since it looked like they had no effect. I just mention it here since I CAN'T MAKE IT NOT WORK anymore (I've all the original setting to what it was before, and it still works...), so maybe the process of changing it all and rebooting and then back is part of the Windows enigma. BTW, this XP Pro machine used to have Win98, which worked correctly for the %J. After the upgrade (not clean install) to XP, the "Remote Downlevel Document" started showing up. Joao Soares Veiga RF COM Sistemas Ltda.>%J is supposed to contain the banner page for the print job, and this >is what is captured by the script. I do not know what you mean by Win2k >double spooling. Is the an intrinsic property of win2k or of someparticular>arrangement you have?>Joel
List members, I found this post on the print job notification that has my exact problem but this solution does not work for me. http://lists.samba.org/pipermail/samba/2002-August/078742.html On all of my print jobs the name of the job comes back as remote downlevel document. This is only for win2k. The win98 print jobs have the correct names for the print jobs. I know this is most likely some win2k issue but if I cannot get it fixed I will be moving the print server back to novell (it was working fine on it). I tried removing the port from my registry and it was added back by windows. That's not a very good soulution anyway because we have roughly 50 pc's to do it to. Can anyone give me an idea of what to try next? It is not in the print command because the win98 pc's work fine. I am printing with cups set up as raw and samba 2.2.5 Thank you. Tony McGrew www.multicam.com