note 68768 added to function.system

From: Date: Thu, 10 Aug 2006 06:43:47 +0000
Subject: note 68768 added to function.system
Groups: php.notes 
Request: Send a blank email to php-notes+get-115745@lists.php.net to get a copy of this message
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! ---- Server IP: 66.163.161.117 Probable Submitter: 196.192.33.237 (proxied: 1.1 BNICL-PROXY) ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.system.php Edit -- https://master.php.net/note/edit/68768 Del: integrated -- https://master.php.net/note/delete/68768/integrated Del: useless -- https://master.php.net/note/delete/68768/useless Del: bad code -- https://master.php.net/note/delete/68768/bad+code Del: spam -- https://master.php.net/note/delete/68768/spam Del: non-english -- https://master.php.net/note/delete/68768/non-english Del: in docs -- https://master.php.net/note/delete/68768/in+docs Del: other reasons-- https://master.php.net/note/delete/68768 Reject -- https://master.php.net/note/reject/68768 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115745) next »