4

I'm working with Netbeans 8.0.2 on Mac. I have problems with exec statements. Within netbeans it seems it can't find commands that are available in terminal.

For example I have this execute statement:

exec('mongorestore --host='.$this->host.' -d '.$this->db_name.' --dir '.$this->schemaPath);

If I run:php restore.php from terminal it runs without incident and imports the data. However if I run/debug/unittest from within netbeans output window shows:

sh: mongorestore: command not found

Other commands like mysqldump also have this issue. How can I make sure these command work from within Netbeans?

To be clear, I can run these commands in the terminal in netbeans, the problem only occurs if I run/debug/unittest a php file.

UPDATE: Running some more test I find that the path variable is different for Netbeans.

terminal: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin netbeans: /usr/bin:/bin:/usr/sbin:/sbin

Jeroen de Lau
  • 640
  • 4
  • 13
  • 1
    After more research it turns out the path variable in shell is not the same as in applications. Mac seems to make it harder and harder to set environment variables. I've tried the latest solutions as listed here: http://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite. That didn't work for me. So I'm starting netbeans from terminal instead. – Jeroen de Lau Nov 06 '15 at 00:49

0 Answers0