osx - How to make it run the `exec()` command in PHP to edit some file in Mac OS X? -
when have php script.
<?php exec('/usr/local/bin/mate hello.txt'); ?>
it doesn't work on web browser http://abc/hello.php, example.
the command of mate 'textmate app', , it's editing hello.txt.
is php permission problem? need run commands on local web server (i'm user), can open permission run seemingly dangerous exec()
function.
- q : how can make run php
exec()
function?
i use mac os x 10.6.6/apache/php5.
added
i guess it's not possible launch php on mac, purposes open textmate editor edit something, using txmt protocol works fine.
solved
in terms of launching application in web browser (especially safari) cannot done php, protocol handler.
launching texteditor edit something.
texteditor provides own protocol handler txmt://open/?url=file://the_file_to_edit"
.
or, can have button edit file when clicked.
<form action="txmt://open/?url=file://file_to_edit" method="post"> <button type="submit">edit</button> </form>
launching other app
you need come own protocol handler. has necessary information example.
for example, launching pathfinder
make url types/schemes @ info.plist.you may want main window pops up. can set application agent
.
pf:
protocol handler. it analyzes input of pf:input_ginven
, input_given
part give parameter pathfinder.
@implementation urlhandlercommand! - (id)performdefaultimplementation { nsstring *urlstring = [self directparameter]; nslog(@"url :=: %@", urlstring); nsarray *components = [urlstring componentsseparatedbystring: @":"]; nsstring* string2 = (nsstring*) [components objectatindex:1]; nslog(@"url :=: %@", string2); [[nsworkspace sharedworkspace] openfile:string2 withapplication:@"path finder"]; [[nsapplication sharedapplication] terminate:nil]; return nil; }
@end
usepf:open_directory
protocol. <form action="pf:direcory_to_open" method="post"> <button type="submit">open</button> </form>
if script running on remote web server, exec()
run on remote server, not local machine. guess want command run on local computer visiting website, not possible (security) reasons.
what want use txmt://
protocol described in textmate manual:
<a href="txmt://open/?url=file://~/.bash_profile&line=11&column=2">open in textmate</a>
Comments
Post a Comment