kavent Posted December 25, 2006 Share Posted December 25, 2006 Hi everyone, I am new to PHP and trying to do something as the following:Allow users to enter their c++ code in text area, which will be saved in main.cpp.Then I tried to run g++ (from /usr/bin/g++) to compile this main.cpp, but nothing happened. It seems that I can't run other programs in /usr/bin/ either.<?php$cmd = "less main.cpp; g++ main.cpp -o test.out;";echo shell_exec($cmd);?>shows main.cpp with no problem, but it doesn't compile. g++ has permission of 755, safe_mode is off, and I don't have root on the server.Any help would be appreciated. Thanks! Link to comment https://forums.phpfreaks.com/topic/31836-problem-with-program-execution-g/ Share on other sites More sharing options...
btherl Posted December 26, 2006 Share Posted December 26, 2006 Try[code=php:0]$cmd = "less main.cpp; g++ main.cpp -o test.out &> /tmp/g++.out;";[/code]And see what you get in /tmp/g++.outIt might help to give the full path too, [code=php:0]/usr/bin/g++ main.cpp[/code] Link to comment https://forums.phpfreaks.com/topic/31836-problem-with-program-execution-g/#findComment-147766 Share on other sites More sharing options...
kavent Posted December 26, 2006 Author Share Posted December 26, 2006 It does work, thanks!However, I don't quite understand the syntax "&> /tmp/g++.out;". Actually, what I tried to do is to use a application called dot, which is similar to g++, to compile DOT file. The commend looks like this:$cmd = "dot test.dot -Tsvg -o test.svg;";Would you help me with this one as well? Thank you! Link to comment https://forums.phpfreaks.com/topic/31836-problem-with-program-execution-g/#findComment-147817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.