exec() with Mac open command

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Billiken
Forum Newbie
Posts: 2
Joined: Wed Aug 25, 2010 9:14 am

exec() with Mac open command

Post by Billiken »

I want to do something like the following:

Code: Select all

exec('open /Applications/Safari.app');
I can run exec on other commands like:

Code: Select all

$output = exec('ls -ll);
echo $output;
And I can run the open command via Terminal, but I can't seem to run the open command via a PHP page using exec().

I've tried the permissions of the .app file at 777 and the open binary at 777.

Any suggestions?
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: exec() with Mac open command

Post by Gargoyle »

if what you are trying to do is call an application like safari and have it suddenly open in a new window or so, this isn't at all possible with PHP.
User avatar
bradbury
Forum Commoner
Posts: 40
Joined: Wed Aug 25, 2010 11:21 am
Location: Eugene, OR

Re: exec() with Mac open command

Post by bradbury »

don't use a mac
Billiken
Forum Newbie
Posts: 2
Joined: Wed Aug 25, 2010 9:14 am

Re: exec() with Mac open command

Post by Billiken »

Gargoyle wrote:if what you are trying to do is call an application like safari and have it suddenly open in a new window or so, this isn't at all possible with PHP.

I'm trying to have the application launch on the machine running php/apache.

I think it may have something to do with the _www apache user. But I don't know what sort of permissions I have to give that user.
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: exec() with Mac open command

Post by Gargoyle »

if you want the program to keep running, you need to redirect its output to a file:

Code: Select all

/dev/null < exec('open /Applications/Safari.app');
I don't know how to do that on Mac though.
Post Reply