Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
macOS: Using pbcopy from PHP does not work

On macOS there is a terminal utility called 'pbcopy' which copies text into the clipboard. pbcopy < file copies the contents of 'file' into the clipboard. But from PHP (running under Apache, both the standard PHP and Apache included in macOS) it does not work. The only difference is that I have changed the Apache user to my username instead of the standard _www or www-data, for convenience of changing files on my development webserver (which is my Macbook Pro). I am running Apache 2.4.33 and PHP 7.3.11 under Catalina 15.3.

system("pbcopy < /Users/me/.profile");

from PHP does not do anything, but also not issue any errors.

system("pbcopy < /Users/me/.profile 2>&1");

to show stderr errors in PHP.

When running from a terminal

/usr/bin/php -r 'system("pbcopy < /Users/me/.profile");'

it does work: the contents of my .profile is copied into the clipboard. I have given /usr/sbin/httpd accessibility access under Settings => Security & Privacy => Accessibility to allow clipboard access.

Why does this not work under Apache ?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!