Jump to content

PHP exec() File Write Problem


heavyJ

Recommended Posts

Alright guys, so in the project I'm working on, we have a number of C++ programs that do read/write to some data files that we created, and I need to call these from a PHP page.

 

Now, I can read and write to the files just fine through PHP, but when I call exec("cpp_program") , the C++ program cannot access the file at all. It runs and prints, but it cannot open a filestream.

 

I believe the permissions on the files that are being read/written are set correctly, so I 'm not sure what's wrong.

 

It's a little urgent, so any help would be very much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/184151-php-exec-file-write-problem/
Share on other sites

Well, it turns out that it was a stupid mistake. The C++ executable and the data files were in one directory and I called them in PHP with exec('bin/cpp_progam'), assuming that the C++ program would look in bin for the data files. Instead, it was looking in the current directory above bin, and couldn't find anything.

 

So I did a chdir() and it worked fine. Thanks anyways everyone.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.