You are not logged in.
Pages: 1
I want to share a printer from a linux host to other windows machines, but I am having a driver issue. Instead, I would like to use a script. Basically, the script would watch a shared folder (e.g. check every 30 seconds). When a file is copied into it, it prints the file, and then deletes the file. I have absolutley no bash experience, how would I go about doing this? I cant even find the command to print a file =p.
Offline
There's several problems with this approach, the biggest that I can see is that the raw printer utilities available from the command line are only capable of handling plain text, postscript, and pdf files. Anything else is going to be questionable results. It's also a bandaid hack, and you're better off fixing the real issue. There's plenty of information available in the wiki and elsewhere about accessing linux hosted printers from windows (with and without samba).
That said, if you're still bent on doing this, don't poll. Use inotify. Something like the following might not toast your cat.
#!/bin/bash
WATCH_DIR=/path/to/watch/dir
while inotifywait -qm -e WRITE_CLOSE --format %f "$WATCH_DIR" | read -r file; do
lpr "$WATCH_DIR/$file" && rm "$WATCH_DIR/$file"
done
Offline
The problem with actually sharing the printer is that the windows machines are complaining about an improper driver on the host (I am using CUPS).
I tried lpr, but my printer just spit out a bunch of blank pages (and caused a couple of jams...), and now that I think about it, could have been caused by the format. However, I just did discover this that works:
soffice -p <document> //prints the document
Since it uses openoffice, should work with plenty of file types. Will try it out and post for the benefit of others.
EDIT:
When I do echo, it is just returning the directory, $file contains nothing. Also, in the script, it triggers every other time, while straight in the command line, it works.
Last edited by rp181 (2011-01-02 23:28:20)
Offline
Are you using Samba? I thought it could do this sort of thing. From memory you set up the Windows clients to print to a samba share configured as a raw queue and Samba sends the file straight to the printer. You need the windows printer driver installed on the clients naturally.
Offline
You don't even need samba. You can configure Windows to print directly to cups on an LPR connection pointing at port 631 (address is something like http://hostname/printers/<printernamehere). I think you have to configure it as an "internet printer".
Been a while since I've done this, but it works. You only need samba for printing if you're trying to print _to_ a Windows machine from Linux.
Offline
The windows machine is complaining about the drivers not being correctly installed on the host, which is the CUPS driver. Port 631 is the cups web interface, and i do have the printer shared in cups, but never figured out how to get that to work. I am going to try this later on, but for now, I put together a quick java program (bash wasn't working for me...) that works wonderfully. This also might actually be more conveniant .
Java program if anyone wants it: http://pastebin.com/nQ8d7UGS
Offline
If you *do* want to use Samba, you should install your printer as a Raw queue (as mentioned above).
Then make a Samba-share pointed to the raw queue, and configure your Windows-boxen to print to that Samba-share.
For myself, I thus installed my printer twice. Once for linux, once for windows.
If you want more info, I can provide part of my smb.conf and the steps I made in CUPS.
Offline
I got that to work, but the raw printer is setting the page size as A4 instead of letter, and there is not option for it. The actual printer is set to letter.
Offline
Pages: 1