The equivalent of copy prn in ubuntu
July 23, 2015 6:13 PM   Subscribe

I currently use an xp computer with the command window (run--> command) to send a file over the parallel port with the "copy prn" command. I haven't been able to figure out how to do this under ubuntu, but need to switch over to using an ubuntu laptop that I have here. Seems like it should be a straightforward task? I am not too clear on what the copy command is doing, really, though, even.
posted by Nish ton to Technology (6 answers total) 1 user marked this as a favorite
 
In Unix, everything is a file. Your parallel printer port should be available as a "file" under /dev.

So if you know the name of the printer device, you should be able to do something like:

cp file2copy /dev/lp0

Where lp0 is the name of the printer device (example, your printer may have a different name).

The trick may be setting up the device driver (kernel module) to enable this and then knowing what the name of the device is.

It might help to have a little more context. Are you just trying to print something?
posted by jclarkin at 6:23 PM on July 23, 2015 [1 favorite]


jclarkin has already given you an excellent answer, but to clarify.. Do you really want to do something as low level as "dump this file to the parallel port?" Or are you really asking "how do I print on Ubuntu?" Those are different questions.

Honestly, the low level parallel port access is pretty old and retro. The good news is Linux is great at old and retro! You may just need to do a bit of poking to figure it out. On my Ubuntu box the parallel port device is named /dev/parport0. It's configured by the drivers ppdev and parport. So cat file > /dev/parport0 is the straightforward equivalent to the DOS command. If you do want to pursue this option more, it'd be helpful to know a few things. What version of Ubuntu? What does dmesg | grep -i parallel say? And what does lsmod say?

If you're just trying to set up sane printing in Ubuntu, this list of guides and the specific guide CUPS - Print Server are good places to start. Fair warning, printing in Unix has traditionally been awkward and complicated. It involves creating print services, and queues, and setting up drivers, and also (usually) filters that convert inputs to the language your printer needs. Ubuntu is pretty good at holding a user's hand through this stuff though.
posted by Nelson at 6:50 PM on July 23, 2015 [1 favorite]


Regarding jclarkin's answer (if indeed you want low level access to the parallel port), the right command would be cat, not cp:

cat file2copy >/dev/lp0

But I never use the parallel port like this so maybe I'm introducing confusion.
posted by pantufla_milagrosa at 7:21 PM on July 23, 2015 [1 favorite]


I'm guessing Nish ton is using this for something like an old eprom programmer or other piece of moderately old, specialized tech. It was a pretty common way of getting bits out of a computer back in the day when serial ports were too slow and USB wasn't yet a thing.

Nish ton, what is this device you're sending data to?
posted by ryanrs at 7:46 PM on July 23, 2015


Are you passing the "/b" switch to the "copy" command on your XP system? If so, then p_m's suggestion is on the money: the Linux equivalent of

copy /b file.prn \\HOSTNAME\PRTRNAME

would be something like

cat file.prn > /dev/lpr

where the name "lpr" depends on your system and how it's configured. I'm not much of a Linux jock, if p_m says it's "lp0" that's what I'd go with.

If you're not using "/b", then Windows may be translating line endings for you; if that behavior is important, you can get the same effect on Linux via other means.
posted by Rat Spatula at 4:53 AM on July 24, 2015


As has been requested above, more details would help a lot.

If you're trying to print a file, and you have the printer on the parallel port set up (System Settings → Printers), the command is:
lp file
There's a very good chance that CUPS, the Linux printer system, has nabbed the parallel port for its own use. If this is not a printer, but is some random parallel device that you can feed files to, you'll probably have to stop the printer system before you can write to the device.

So, more deets, or we can't help.
posted by scruss at 7:33 AM on July 24, 2015


« Older Are potential employers finding something negative...   |   Iceland with young boys over Christmas Newer »
This thread is closed to new comments.