Jump to content

Problem: system() binary programs using the browser


mikezian

Recommended Posts

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

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];

}

}

?>

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

(

)

 

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.