Most primitive way to print a file (file --> printer).
Hi:
What is the mos primitive way to output a file to the printer? I mean data transfer from the file to the printer. I suppose it must be 'cp some_file /dev/<printer device>. For the console, I know the devices are /dev/ttyN, N= 1,2,... But I do not know what are the devices for the printer. Thanks Thanks. |
|
More or cat should work also.
lpt is a basic mode. /dev/lp0 http://discussions.virtualdr.com/showthread.php?t=71241 |
Thanks for the links. It'll take some time to study them.
I'll do 'cp file1 /dev/lp0'. But what if I want to send some control chars. Or a shell script would suffice? That is: suppose I send them in the form 'cp <some control chars> /dev/lp0'. What would be the syntax for <some control chars>? |
Code:
printf "This is a test\r\n\f" | lpr Direct a postscript file to a postscript language printer. Example Code:
cat myfile.ps > /dev/lpt0 Example Code:
nc nethplaser 9100 < myfile.ps |
Thanks for your post, teckk. From the manual, lpr seems to be far from being a primitive command. By primitive I mean the number of layers of software between the command and the hardware.
Also, printf, is a sofisticated command. There must be some way to send control chars with cp or cat. Perhaps cat \0x0a /dev/lpt0 ? |
Maybe using a pipe with the echo command?
|
So a shell variable can contain non-printable chars? And cannot these chars be embedded in an ascii text file?
|
Quote:
Example Code:
cat file.ps > /dev/ulpt0 Quote:
Code:
printf "This is a test\r\n\f" | cat > /dev/ulpt0 Or you could echo the character you want to the device node. You can write a shell script to automate that perhaps. Why don't you post what you are trying to achieve and someone might be able to direct you. If you are trying to access a printer, make carriage returns, line feeds, so that the document prints correctly, That's what a print driver, a PCL filter that calls upon ghostscript, or sending the document in the same printer language that the printer understands does. If you cat a .txt file to a PCL printer without a filter the txt will be all mixed up. Sounds like you already know that and are trying to make a print filter or printer driver for a particular printer language? Just simply making a text file with control characters in the text won't give you what you want I don't think. |
Thanks for your kind reply, teckk. If my file is 3 chars long, consisting of the string 'abc', then cat > /dev/lp0 will result in the string 'abc' being efectively printed on the paper. I never did it, but that's what in this thread has been said, and what common sense dictates.
What am I trying to do?: I have an old dot printer, connected to a paralell port in the machine. Some chars are typed in bold and some not (single and double strike of the needles). When turning on power, the printer should initialize, although always some settings are done by the user by means of dip switches on the printer rear panel. The computer program writting to the printer has always priority over the these hardware switches. I have the printer manual, including the colection of control chars it recognizes. And intend to send some of them, in an atempt to correctly inizilize it, an operation with low probabilities of success (I blowed a fuse up and had to open it; BEFORE THIs it worked pretty nice). I hope I did not went very much away from the subject title. Regards. |
All times are GMT -5. The time now is 03:00 PM. |