Re: how to execute Exe file in system

From: Date: Fri, 17 Feb 2012 12:19:00 +0000
Subject: Re: how to execute Exe file in system
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-316666@lists.php.net to get a copy of this message
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/

« previous php.general (#316666) next »