On Fri, Feb 17, 2012 at 2:19 PM, Stuart Dallas <stu...@3ft9.com> wrote:
> On 17 Feb 2012, at 12:12, Negin Nickparsa wrote: > > if (($out = system(' "C:/Program Files/GAMS23.7/gams.exe "C:/Program > > Files/GAMS23.7/trnsport_php.gms')) !== FALSE) > > { > > print('Not error!'); > > printf('Output is "%s"', $out); > > } > > else > > { > > print('Error'); > > } > > Fatih it shows again nothing why I should set the full path even when I > run > > my file on the path I don't think so that it is needed I don't know how > to > > work with these quotations was it right Duken? > > > * Use back ticks to get the full output. > * Use escapeshellcmd and escapeshellarg to ensure the command is built in > a safe and valid way. > * Redirect stderr to stdout using 2>&1 so you see any error messages that > are being generated. > > $cmd = escapeshellcmd('C:/Program Files/GAMS23.7/gams.exe').' > '.escapeshellarg('C:/Program > Files/GAMS23.7/trnsport_php.gms').' 2>&1'; > $out = `$cmd`; > var_dump($out); > > Try that, then you can build logic that checks the output for errors. You > may also want to make sure that safe_mode is disabled, though I doubt > that's the problem. > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/ it is espacing issue as Stuart stated.. try this one thats working for me with spaces //$out = shell_exec("\"C:/Program Files/tws_date.exe\""); tws_date is c program prints date. nothing special $out = shell_exec("\"C:/Program Files/GAMS23.7/gams.exe\" \"C:/Program Files/GAMS23.7/trnsport_php.gms\""); if ($out) { echo "OK: " . $out; } else { echo "ERROR"; } var_dump($out);