mikezian Posted March 31, 2007 Share Posted March 31, 2007 I'm having problems running binary programs with arguments using system() through the web...Running through cli is not a problem I'm not having any trouble running this code from the browser since the binary program doesn't receive any arguments Here's my code: <?php error_reporting(E_ALL); ini_set('display_errors','on'); $out = system("/usr/local/bin/timidity"); echo "<pre>"; print_r($out) /* Add redirection so we can get stderr. */ ?> Output: TiMidity++ version 2.13.0 -- MIDI to WAVE converter and player Copyright © 1999-2004 Masanao Izumo Copyright © 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA But when I pass some arguments like '--help', it runs perfectly in cli mode Here's my code: <?php error_reporting(E_ALL); ini_set('display_errors','on'); $out = system("/usr/local/bin/timidity --help"); echo "<pre>"; print_r($out) /* Add redirection so we can get stderr. */ ?> Here's the output TiMidity++ version 2.13.0 © 1999-2004 Masanao Izumo <[email protected]> The original version © 1995 Tuukka Toivonen <[email protected]> TiMidity is free software and comes with ABSOLUTELY NO WARRANTY. Usage: timidity [options] filename [...] Use "-" as filename to read a MIDI file from stdin Options: -A n,m --volume=n, --drum-power=m Amplify volume by n percent (may cause clipping), and amplify drum power by m percent (a) --[no-]volume-compensation [etc...] But when I ran it on the browser, the output is blank Hope somebody can help me on how to resolve this Mike Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/ Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 First What Its Showing <?php $tst[] = 'exec'; $tst[] = 'system'; $tst[] = 'shell_exec'; for($i=0;$i<3;$i++) { if(!function_exists('system')) { echo "Function Disabled ".$tst[$i]; } else { echo "Function Enabled ".$tst[$i]; } } ?> Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218520 Share on other sites More sharing options...
mikezian Posted March 31, 2007 Author Share Posted March 31, 2007 I've never had any problem executing '/usr/local/bin/ffmpeg' with arguments using system(). Its kinda weird that I'm having trouble executing '/usr/local/bin/timidity' with arguments Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218525 Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 OK Run the above Script And Tell What Its Showing Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218528 Share on other sites More sharing options...
mikezian Posted March 31, 2007 Author Share Posted March 31, 2007 Function Enabled execFunction Enabled systemFunction Enabled shell_exec Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218529 Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 Ok Try using exec in the place of system. Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218531 Share on other sites More sharing options...
mikezian Posted March 31, 2007 Author Share Posted March 31, 2007 Here's my code: //86.mid resides on the same directory as the script echo "Executing timidity without arguments"; echo exec("/usr/local/bin/timidity",$output); echo "<pre>"; print_r($output); echo "</pre>"; echo "<br>Executing timidity with arguments"; echo exec("/usr/local/bin/timidity -Ow 86.mid",$output2); echo "<pre>"; print_r($output2); echo "</pre>"; Here's the output: Executing timidity without arguments Array ( [0] => TiMidity++ version 2.13.0 -- MIDI to WAVE converter and player [1] => Copyright © 1999-2004 Masanao Izumo [2] => Copyright © 1995 Tuukka Toivonen [3] => [4] => This program is free software; you can redistribute it and/or modify [5] => it under the terms of the GNU General Public License as published by [6] => the Free Software Foundation; either version 2 of the License, or [7] => (at your option) any later version. [8] => [9] => This program is distributed in the hope that it will be useful, [10] => but WITHOUT ANY WARRANTY; without even the implied warranty of [11] => MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [12] => GNU General Public License for more details. [13] => [14] => You should have received a copy of the GNU General Public License [15] => along with this program; if not, write to the Free Software [16] => Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA [17] => ) Executing timidity with arguments Array ( ) Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218540 Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 Test It if(!exec("/usr/local/bin/timidity -Ow 86.mid")) { echo "False"; } else { echo "true"; } Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218551 Share on other sites More sharing options...
mikezian Posted March 31, 2007 Author Share Posted March 31, 2007 Output: false Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218552 Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 So It Cant Get Executed With This Parameters Try this In Shell /usr/local/bin/timidity -Ow 86.mid Link to comment https://forums.phpfreaks.com/topic/45005-problem-system-binary-programs-using-the-browser/#findComment-218553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.