Initial Query
I have a .ps file that I want to print from my mac. I'm trying to use lpr. But every time I print it all I get is the actual bytes just printed with like hundreds of pages and this is not what I want. I want the printer to just print the ps directly. What command should I use to make this work?
LLM Generation
Query
I have a .ps file that I want to print from my mac. I'm trying to use lpr. But every time I print it all I get is the actual bytes just printed with like hundreds of pages and this is not what I want. I want the printer to just print the ps directly. What command should I use to make this work?
Output
Okay, the problem you're describing is classic: the printing system (CUPS, which `lpr` uses on macOS) is treating your PostScript file as plain text instead of interpreting it as page description commands.
You need to tell `lpr` (and CUPS) to either send the file *raw* to the printer (if the printer understands PostScript natively) or to correctly identify it as PostScript so the appropriate filter can process it.
Here are the commands to try, starting with the most likely solution:
1. **Use the `raw` option (Best for PostScript Printers):**
This tells CUPS to send the file directly to the printer without any filtering. This works perfectly *if your printer natively understands PostScript*.
2. **Let CUPS Auto-Detect (Should work if configured correctly):**
If your printer queue is set up correctly (especially if it's *not* a native PostScript printer but has a driver that can handle PS input via filtering), CUPS *should* auto-detect the file type based on the `.ps` extension or content and apply the necessary filters (like using Ghostscript internally). Sometimes just running `lpr` without options works if the system is set up right.
If this command produced the gibberish output, then either your printer doesn't understand raw PostScript *and* CUPS isn't filtering it correctly, or your printer *does* understand PostScript but CUPS tried to filter it anyway. The `-o raw` option from step 1 bypasses this potential mis-filtering.
3. **Specify the Printer Explicitly:**
Maybe the issue is with your default printer queue. Try specifying the printer queue name explicitly. First, find your printer's queue name:
Look for the printer name in the output. Let's say it's `My_LaserJet`. Then try printing:
| # Try with auto-detection to the specific printer
lpr -P My_LaserJet yourfile.ps
# Or try sending raw to the specific printer
lpr -P My_LaserJet -o raw yourfile.ps
|
4. **Convert to PDF first (Reliable Workaround):**
macOS has excellent PDF handling, and CUPS generally processes PDF files very reliably. You can convert your PostScript file to PDF first using the built-in `pstopdf` utility.
| pstopdf yourfile.ps
# This will create yourfile.pdf in the same directory
# Now print the PDF
lpr yourfile.pdf
|
This is often the most robust method if you encounter issues with direct PostScript printing, as it leverages the well-tested PDF filtering pipeline in CUPS.
**In summary:**
* Try `lpr -o raw yourfile.ps` first, especially if you know your printer supports PostScript.
* If that doesn't work or prints garbage (meaning your printer likely *doesn't* natively support PostScript), try the PDF conversion method: `pstopdf yourfile.ps` then `lpr yourfile.pdf`.
* Make sure your printer is correctly configured in macOS System Settings -> Printers & Scanners with the appropriate driver. Sometimes removing and re-adding the printer can fix configuration issues that prevent proper filtering.
Check if any of the following conditions are true:
Substring Evaluation
Testing if the previous output contains the string -l
: False
Substring Evaluation
Testing if the previous output contains the string -o raw
: True
Final Answer: True