LPD For Fun and MP3 Playing 122
poop writes "Most true Unix geeks will recognize just how nice LPD is as a distributed queueing mechanism for managing all jobs sent to the printer. But, what most people don't realize is that LPD can be used for other things too. In fact, it can be viewed as a general queueing mechanism with a few added bells and whistles for printers. So let's examine a more interesting use of LPD, an engine for distributed spooling of MP3s." Bruha points out this mirror.
geez (Score:5, Informative)
lpd is quite cool. i've used it to queue software builds on remote machines where we aren't given ssh accounts. it's pretty slick.
The Power of 'Dumb' Tools (Score:2)
This is just another example of the power of simple, 'dumb' design, especially at the low levels of the protocol stack: Unix says that 'everything is a stream of bytes' and so does TCP/IP, having been heavily influenced by Unix. Even though it's called 'Line Printer Daemon', it is written generally enough to be used to queue any stream of bytes. As a transport mechanism, it need not know any
Re:The Power of 'Dumb' Tools (Score:2)
After all the average slashdot reader is far more likely to know more about mechanics than about unix...
So? (Score:4, Interesting)
Re:So? (Score:1)
Re:So? (Score:3, Interesting)
Re:So? (Score:3, Interesting)
maybe use samba (Score:1)
There was an article a couple months ago in Linux Journal, i believe, with instructions on using a smb-shared "printer" on your linux box to run files through ghostscript in order to get PDFs out.
I can't try it out right now but i hope this gives someone an idea.
Site is slashdotted; article text (Score:5, Informative)
-- article --
May 23, 2003
LPD for fun and MP3 playing
Background
Most true Unix geeks will recognize just how nice LPD is as a distributed queueing mechanism for managing all jobs sent to the printer. It has a beautiful simplicity to it, and some mean power to go along with it. It's a difficult beast to tame, but once you understand it, everything will start coming out exactly like you want it.
But, what most people don't realize is that LPD can be used for other things too. In fact, it can be viewed as a general queueing mechanism with a few added bells and whistles for printers. So let's examine a more interesting use of LPD, an engine for distributed spooling of MP3s.
Motivation
The main thing that got me started on this quest was seeing these two pictures (one, two) from the c2k3 openBSD hackathon I saw that obviously someone else had figured out how to do it. I sure as heck could also.
Initial Assessment
The first stop on my quest was examine the all-knowing seer of the Internet, google. That returned a wonderful page in Swedish about how to do this very task. Unfortunately, my swedish sucks, but thankfully the scripts were written in bash, and the other big thing was just a printcap file.
Creating a Printcap Entry
The first thing that you need to do is to create an entry in your printcap file for your shiny new mp3 printer. On most systems this file is
mp3:\
Now we'll walk through the entry line by line. I'll ignore the \ at the end of almost every line, that just tells lpd to keep reading because there is more to come. The last line doesn't need the \ obviously.
* 1: mp3: - the name of your mp3 printer. In this case, just mp3
* 2:
* 3:
* 4:
* 5:
* 6:
An Audio Input Filter
The key to the whole system is that all of the processing is done by input filter. On some platforms this may cause it say that the printing has stalled while a song is playing, but that's not a big deal. There is no output from the input filter, and thus nothing is done after this. You'll want to put the following piece of code on your system as
#!/bin/bash
#
# This script was originally made by Teddy Hogeborn.
# Small alterations was made by:
# Peter Lundqvist
# Patrick Wagstrom
#
# This is a "printer filter" for playing audio files
for arg in "$@"; do
case "$arg" in
-d*) dir="${arg#-d}"
-e*) basefile="${arg#-e}"
-f*.*) ext="${arg##*.}"
esac
done
mp3player="mpg123 -q -o oss";
modplayer="mikmod --quiet --playmode 0 --noloops --
Re:Site is slashdotted; article text (Score:1)
Re:Site is slashdotted; article text (Score:1)
Re:Site is slashdotted; article text (Score:1)
Re:Site is slashdotted; article text (Score:5, Informative)
So this finally answers the question of "can slashdot destroy a low grade consumer broadband connection?". Incidentally, the load on the server is still around 0.4. I think it peaked out around 0.8.
Sigh...slashdot needs a distributed automated mirroring service.
And if you're wondering, I did the article on my weblog because people on deadly [deadly.org] were asking about how to do it. On guy even thought they had a sound device (remember the speech thing?) connected to the parallel port doing it.
Re:Site is slashdotted; article text (Score:5, Funny)
Re:This is so CLEVER ! (Score:2)
As I said, they're easy to get.
Oh, and they'll probably mod this one down too, but I still don't care. Notice I'm leaving the karma bonus on to really drive the point through your thick skull.
Daniel
Good hack, litteral sense (Score:5, Funny)
Next in line, "sendmail configuration files used as crypto keys"
Re:Good hack, litteral sense (Score:1)
Too late, someone's already done it [sourceforge.net]... comes with remote file playback as well.
Re:Good hack, litteral sense (Score:3, Informative)
Re:Good hack, litteral sense (Score:2)
So if you had say 2 people on the commity (that's "no more than 3", and both were absent, you'd get stuff done?
Re:Good hack, litteral sense (Score:2)
Re:Good hack, litteral sense (Score:1)
sendmail configuration files used as crypto keys (Score:1)
[simple, but working, encryption/decryption script]
Lameness Filter Encountered
Reason: Use fewer "junk" characters.
Your comment has too few characters per line (currently 29.8).
So, since I can't be bothered to start a sourceforge project, I guess we'll just have to forget it.
lpd generic wrapper libs in C/C++/Java/...? (Score:5, Interesting)
Given what one can do with ghostscript queues, this is not exactly rocket science, but it goes to show the flexibility of *nix once again.
Re:lpd generic wrapper libs in C/C++/Java/...? (Score:2)
Interesting idea. Personally, I would like to see a Win32 client for sending (via explorer, not IE, but explorer) audio files to the remote server. I suspect that this could be done via the Windows printing system but it could get dirty--you'd probably need a custom printer driver.
Chris
Useless... (Score:5, Funny)
Re:Useless... (Score:1)
Funky, but (Score:5, Funny)
Apart form that looks very fun for a small network with shared sound.
Re:Funky, but (Score:1)
Re:Funky, but (Score:1)
although the further you take the concept you may as well make a whole program (web based or whatever) and forget using LPD
Well, I startet writing something like that in bash. There are still many things to improve, but it's working quite nicely for me: http://muff.sourceforge.net
Re:Funky, but (Score:2)
Article mirror (Score:3, Informative)
And enjoy. Don't mod me up though, it would be karma-whoring.
And wanted to add that the idea isn't new as you can see in this recent thread on deadly.org here [deadly.org] (See post "mp3's playing via lpr?").
Re:Article mirror (Score:2)
No offense, but did it occur to any of you karma-whoring jackasses to mirror the images?
Chris
Most unix geeks (Score:1)
Re:Most unix geeks (Score:1)
Old news ;-) (Score:2)
Re:Old news ;-) (Score:1)
I wouldn't normally do this but OpenBSD really does rock; it's cool (but not surprising) that this has come from the hackathon news. I'm quite sure there'll be lots more interesting stuff to come from the most recent and future ones (with or without funding
Been there, done that (Score:3, Interesting)
It was actually quite successful and kept my house in 24x7 music for about four years. Unfortunately, I retired all of my lpd-based printers and started using CUPS, so I also killed the mp3 queue too.
lpd is nice? (Score:4, Interesting)
Re:lpd is nice? (Score:1)
Re:lpd is nice? (Score:2)
Re:lpd is nice? (Score:1)
Granted the printer is fairly old but so what, I'm not going to buy new hardware just to be able to run Windows.
You never said when you installed Linux, things are moving pretty fast you now.
Re:lpd is nice? (Score:2)
Re:lpd is nice? (Score:1)
Re:lpd is nice? (Score:1)
All I can say is that Mandrake 9.1 autodetected it and it works fine.
If you're using KDE k3b is by far the best burning app you can get, nicely integrated with Konqueror and all.
Re:lpd is nice? (Score:1)
Re:lpd is nice? (Score:1)
I genuinely tried to install linux for a desktop OS, and ran into more problems with printing than anything else.
I had the same troubles until I settled on CUPS and KDE. Absolutely z.e.r.o. problems. This is with high-end (duplexing, finishing, faxing) mopiers and plain-jane inkjets too. Just beware the WinPrinters.
Re:lpd is nice? (Score:2)
But LPD *IS* simple... The complexity involved is due to the print filters most people use along with LPD. If you have a postscript print (thus need no filter), an amature can setup LPD (referencing the man page) in about 5 minutes.
All too often I've wished people would think about the consequences of their printfilter design. Ghostscript is fairly lowsy
CUPS also (Score:5, Informative)
Some fun things I've done with backends:
Network printing over SSH
Text-to-speech queueing (print your source code to hear it read aloud by festival)
Dumping into a jpeg as a way of snapshotting any document you might want to save
Dumping into a PDF with ps2pdf to make your Windows friends feel stupid for buying Distiller =)
Re:CUPS also (Score:1)
Re:CUPS also (Score:3, Informative)
pstopnm -stdout file.ps | pnmtojpeg > file.jpeg
Both of those filters are in the netpbm package:
http://netpbm.sourceforge.net/
Re:CUPS also (Score:3, Informative)
Re:CUPS also (Score:1)
Re:CUPS also (Score:1)
Network printing over SSH Text-to-speech queueing (print your
Hmm if I were going to list the fun things I've done with backends, it probably wouldn't include using printers...
DNS zone transfers (Score:3, Funny)
so an error could message may be (Score:5, Funny)
Re:so an error could message may be (Score:1)
HIgh End Queuing? (Score:3, Insightful)
That takes alot of paper! (Score:5, Funny)
ldp old (Score:1)
Responsible Reporting (Score:4, Interesting)
Sure, report news as needed, but before *linking* ASK them if they can deal with the load.. or the cost after being hit hard..
This is getting really bad, and i can feel a 'anti-slashdot' movement growing over this sort of thing.
Re:Responsible Reporting (Score:2)
And forget about caching the pages on
Forget T1's (Score:2)
Or the tiny personal web pages that cap # of hits...
Re:Responsible Reporting (Score:1, Flamebait)
1. For the slashdot crowd to stop regarding "the slashdot effect" as some sort of penis substitute.
2. For Rob and Taco to actually spend 0.00001 seconds pondering the concepts of "ethics" and/or "professionalism."
Not gonna happen in a million years.
Re:Responsible Reporting (Score:3, Funny)
Well, in that case, warn this guy that his page will be slashdotted early next week, when the dupe story gets posted.
Chris
If I accidentally print an MP3... (Score:5, Interesting)
Re:If I accidentally print an MP3... (Score:2)
Re:If I accidentally print an MP3... (Score:1)
+1. I'm not conservative, I just find your sig irritating.
Re:If I accidentally print an MP3... (Score:1)
Huh ? (Score:3, Funny)
However, for real geekiness, you should be using gridengine to queue and distribute your mp3s.
Mirror Here (Score:1)
I'm sure it's very nice... (Score:5, Funny)
...until you accidentally spool that mp3 to the printer ;)
Re:Old, old news. (Score:1, Funny)
Useful for 3D animation (Score:2)
How cool! I can't wait to try it!
So sick of this! (Score:4, Funny)
Oh they're not?
Well.. How DARE SCO sue this guy for using...
Err, wait..
This is an article.. about someone using software technology... to accomplish a task... and there's no litigation involved???
OH MY GOD!!!!
Innovation w/o Litigation is a Temporary Situation (Score:2)
Did it with cups! (Score:4, Funny)
Steps are simple:
1. uncomment
#application/octet-stream
at the very end of
3. drop this
---
#!/bin/bash
if [ $# = 0 ] ; then
echo network audioplay \"Unknown\" \"Audio Player\";
exit 0;
fi
----
in
chmod it +x and restart cups
4. Add printer in cups:
name: audio
location:
description: Hacked Audio-playing CUPS
device: Audio player
(if you don't see this device, you probably haven't restarted cups or audioplay is not executable)
device uri: audioplay://unused/
make: raw
model: rawqueue
4. cat your_favourite.ogg | lpr -r -Paudio
you can also do
lpr -Paudio -r song.mp3
but be careful, lpr likes to delete file after printing.
5. Prof^WEnjoy!
Re:Did it with cups! (Score:2)
Re:Did it with cups! (Score:1)
Oh, the hillarity! Great way to convert people to Linux, have them destroy their music collection.
BTW, this doesn't even work. It will play the first file sent to the queue, and the rest pass simultaneously, like Taco Bell through a Perl coder. Anyone know how to get this code to work so that it actually queues the music files, and isn't just an archaic frontend to mplaye
Re:Did it with cups! (Score:1)
`man lpr` says that it deletes the file, post printing.
Re:Did it with cups! (Score:2)
But I've noticed lpr tried to delete file (it's hard to do from CD
And it works for me, queuing like it should.
lpd for astronomical images (Score:1)
Securitah Warning (Score:3, Interesting)
Beware, these scripts appear to be vulnerable to to un-escaped shell command characters (ie ', ", &, etc) in the filename. The script does not do any validation of the file that is sent to it. Since LPD doesn't do any authentication by default, be very careful about running this stuff on a public-accessible machine.
Chris
Question......... (Score:2)
lpd isn't even good for printing (Score:2)
lpd, lprng, and cups all have a nasty habit of getting into weird states. And lprng and cups can also be a b*tch to configure.
Great for serializing database updates, too... (Score:1)
mirror (Score:1)
I'm still afraid to run LPD (Score:1)