Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6876257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:27:17+00:00 2026-05-27T04:27:17+00:00

I am trying to spool a file to a printer attached to the server

  • 0

I am trying to spool a file to a printer attached to the server using PHP.

I send a command such as lp -d 'Brother_QL-570' '/Users/user_name/Documents/wwwroot/mmsprint/mmsUw8Vv9 using EXEC in PHP and get a return value of 5. The command works fine in the terminal window.

If I send ls, whoami etc, the command executes fine.

whoami and ls live in /bin, so I created a symbolic link for lp and that made no difference.

Also tried /usr/bin/lp and that did not work either. I’m pulling what little hair I have left out over this.

Safe mode is off. The path variables are the same between PHP and my terminal environment.
I am running MAMP on Lion.

FWIW, the command cat /Users/user_name/Documents/wwwroot/mmsprint/mmswKJqYK | lp -d Brother_QL-570 has a return value of 133.

This is my code:

$temp_file = tempnam("./", 'mms');
$pdf->Output($temp_file, "F");
$pdf->Close();
$cmd = "lp -d 'Brother_QL-570'  '".$temp_file."'";
exec($cmd,$output,$retval);
error_log("-----cmd=".$cmd."\n", 3, "printCard.log");
foreach ($output as $a) {
    error_log("-----output=".$a."\n", 3, "printCard.log");
}
error_log("-----retval=".$retval."\n", 3, "printCard.log");

Any thoughts? What am I missing? This should be easy. Argh!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:27:17+00:00Added an answer on May 27, 2026 at 4:27 am

    What is the output from the command?

    Most likely the PHP user (apache probably) has no permission to print things. Add that user to the lp group. (Assuming macs work similar to unix in this.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send an email using smtplib using the low-level commands such as
I'm trying to obtain the full path of the server's desktop using a plsql
I'm trying to scrape a remote website. I'm using PHP Curl, and my code
I'm trying to create a basic video file using OpenCV (in Python). I have
Trying to setup an SSH server on Windows Server 2003. What are some good
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I'm using Delphi 2009 and the MS Access Interop COM API. I'm trying to
I'm trying to spoof the android player. I want MediaPlayer (I'm using the VideoView
Trying to write a windows speech recognition macro. Written using XML and scripting language

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.