macOS: Using pbcopy from PHP does not work
Get the solution ↓↓↓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 ?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: xmlhttprequest error flutter
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.