note 68768 deleted from function.system by googleguy

From: Date: Tue, 22 Oct 2013 14:58:59 +0000
Subject: note 68768 deleted from function.system by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197267@lists.php.net to get a copy of this message
Note Submitter: dotmg at wikkàwiki dot ORG ---- In system($command), $command cannot contain no more than two doublequotes. (At least with 4.3.3, on Windows). IF the path+executable name contains any space (and thus enclosed in double quotes). <?php /** * This example works fine, there is only 2 double quotes */ system ("\"c:\\program files\\myapp\\myapp.exe\" params_for_myapp"); /** * This one will fail, php will complain sthg like c:\\program is not an executable */ system ("\"c:\\program files\\myapp\\myapp.exe\" \"One param for myapp that contains space\""); // /** * If you want your script to be able to run with older version of PHP (like 4.3.3), this is a trick: * Save the command in a temporary file and call that file */ $tmpnam = tempname($writable_dir, "temp").".bat"; $fp = fopen ($tmpnam, "w"); fwrite($fp, $command); fclose ($fp); system($tmpnam, $status); unlink($tmpnam); ?> Note: In my preview, backslashes were gone!

« previous php.notes (#197267) next »