note 80612 added to ref.exec

From: Date: Fri, 25 Jan 2008 07:00:46 +0000
Subject: note 80612 added to ref.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-135392@lists.php.net to get a copy of this message
The note is about usage of exec() under windows... In replay to k dot mitz dot NO_SPAM at att dot NO_SPAM dot net: why not enclose your $cmd in simple quotes instead? Here is where i'm at right now (also TRYING to use exec() and passthru() on windows XP sp2): you can do this: $cmd = '"C:\my path with spaces\targetapp.exe" C:\mypathnospaces\targetfile.xxx'; exec($cmd); The above works. ________ Or, you can put your script into your directory C:\my path with spaces\, and work with php directly from there: $cmd = 'targetapp.exe "C:\my other path with spaces\targetfile.xxx"'; exec($cmd); The above also works, provided of course your script has the correct working directory. ________ But... In your cmd.exe, you can issue: "C:\my path with spaces\targetapp.exe" "C:\my other path with spaces\targetfile.xxx" Although the above works perfectly in the cmd, the following php script does NOT work on my system: $cmd = '"C:\my path with spaces\targetapp.exe" "C:\my other path with spaces\targetfile.xxx"'; exec($cmd,&$content); Not that it sends an error, it just does nothing, and you get nothing written into your $content array... Not that I do understand why. ________ As far as my few tryings go, the root of the problem lies in the fact that the command to execute has two passages enclosed inside double quotes. Another command which I've had working in the cmd but NOT with php is: '"C:\my path with spaces\Apache2\bin\Apache.exe" -w -n "Apache2" -k restart' Maybe someone has a solution; I don't (other than using chdir). ---- Server IP: 217.174.196.197 Probable Submitter: 90.55.30.10 ---- Manual Page -- http://www.php.net/manual/en/ref.exec.php Edit -- https://master.php.net/note/edit/80612 Del: integrated -- https://master.php.net/note/delete/80612/integrated Del: useless -- https://master.php.net/note/delete/80612/useless Del: bad code -- https://master.php.net/note/delete/80612/bad+code Del: spam -- https://master.php.net/note/delete/80612/spam Del: non-english -- https://master.php.net/note/delete/80612/non-english Del: in docs -- https://master.php.net/note/delete/80612/in+docs Del: other reasons-- https://master.php.net/note/delete/80612 Reject -- https://master.php.net/note/reject/80612 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135392) next »