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

  • Home
  • SEARCH
  • 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 3979246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:08:46+00:00 2026-05-20T05:08:46+00:00

When I have this PHP script. <?php exec(‘/usr/local/bin/mate hello.txt’); ?> It doesn’t work on

  • 0

When I have this PHP script.

<?php
    exec('/usr/local/bin/mate hello.txt');
?>

It doesn’t work on web browser with http://abc/hello.php, for example.

The command of mate is ‘TextMate app’, and it’s just for editing hello.txt.

Is this some php permission problem?
I just need to run some commands on my local web server (I’m the only user), so I can open the permission to run this seemingly dangerous exec() function.

  • Q : How can I make it run the PHP exec() function?

I use Mac OS X 10.6.6/Apache/PHP5.

ADDED

I guess it’s not possible to launch something with PHP on my Mac, but for my purposes to open an TextMate editor to edit something, using txmt protocol works perfectly fine.

SOLVED

In terms of launching an Application in web browser (especially Safari) cannot be done with php, but with protocol handler.

Launching TextEditor to edit something.

TextEditor provides its own protocol handler txmt://open/?url=file://THE_FILE_TO_EDIT".

Or, you can have a button to edit the 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 to come up with your own protocol handler. has all the necessary information with an example.

For example, for launching PathFinder

Make URL types/schemes at Info.plist.

You may want to main window that pops up. You can set Application is agent.

enter image description here

Make the pf: protocol handler.

It just analyzes the input of pf:INPUT_GINVEN, to get the INPUT_GIVEN part to give it as a parameter to 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

Use the pf:OPEN_DIRECTORY protocol.

<form action="pf:DIRECORY_TO_OPEN" method="post">
    <button type="submit">Open</button>
</form>
  • 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-20T05:08:47+00:00Added an answer on May 20, 2026 at 5:08 am

    If the script is running on a remote web server, then the exec() will run on the remote server, not the local machine. My guess is you want the command run on the local computer that is visiting the website, but this is not possible for very good (security) reasons.

    What you probably want to use is the txmt:// protocol as described in the Textmate Manual:

    <a href="txmt://open/?url=file://~/.bash_profile&line=11&column=2">Open in Textmate</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple php script <?php echo '<pre>'; // Outputs all the result
I have been writting a keyword search script based on this tutorial: http://www.hackosis.com/2007/11/06/howto-simple-search-engine-with-php-and-mysql/ Like
I have this php code, with which I am trying to generate a popup
I have this PHP code echo '<a href=# onclick=updateByQuery(\'Layer3\', ' . json_encode($query) . ');>Link
Say i have this PHP code: $FooBar = a string; i then need a
This is driving me crazy. I have this one php file on a test
I have this code <?php session_start(); if (isset($_GET[cmd])) $cmd = $_GET[cmd]; else die(You should
I have this rewrite rule RewriteEngine On RewriteBase /location/ RewriteRule ^(.+)/?$ index.php?franchise=$1 Which is
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),
I have a JavaScript function, pop_item . I have to call this from PHP,

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.