|PHP Developers Network
|problem using system() in linux
|Page 1 of 1|
|Author:||wassersohn [ Fri Jul 09, 2010 1:21 pm ]|
|Post subject:||problem using system() in linux|
Hi everyone!, I'm working with PHP and I am having some problems with the system function. I hope you can help me, please.
First of all, I'm using lampp (xampp for linux) and ubuntu 10.4. In my server, in a directory located in /opt/lampp/htdocs/iris I have a program made in c which I need to execute but, when I do it, system returns an error. I replace that program to another that only has a cout and it returns an error too so the program it's not the problem, is the way that I call it or something like that. I wrote exactly this:
$resultado = system("./main libor ./datos/n4/4.jpg ./datos/n4/4.cod ./datos/n4/4.err);
and in $resultado it returns false so the program fails. I have used umask(0) and chmod("nombrearchivoX",0777) in order to made all the archives that I'm using reachable for all type of users.
I executed the command that I'm passing to system manually and it all goes well!, and I'm in the correct directory because I do a system("ls") and the program is there.
In the same directory, if I write an linux script and I use system("nameofthescript") it all goes well!! why not when I'm using a C++ compiled program??
Why can't I execute the program?, what am I doing wrong??
Thanks for all, all suggestions are welcome.
|Author:||VladSun [ Tue Jul 13, 2010 1:25 am ]|
|Post subject:||Re: problem using system() in linux|
Try using absolute file paths (i.e. /directory1/directory2/main) for the command itself and its arguments.
Also redirect stderr to stdout like this
|Page 1 of 1||All times are UTC - 5 hours|
|Powered by phpBB® Forum Software © phpBB Group