06-27-2013
|
|
مدیر کل سایت کوروش نعلینی
|
|
تاریخ عضویت: Jun 2007
محل سکونت: کرمانشاه
نوشته ها: 12,700
سپاسها: : 1,382
7,486 سپاس در 1,899 نوشته ایشان در یکماه اخیر
|
|
To run your command in the background on Windows, you have to use start /B before your command (in Linux add & after your command). exec() simply uses cmd /C. The /C carries out the command specified by the string and then terminates.
However start /B needs to be put before that, so you cannot use exec() for running a command in the background on Windows. Instead use popen. Example: pclose(popen('start /B php yourscript.php > result.txt 2> error.log', 'r')); works.
But what if you have spaces in your filenames? Escape them with double quotes:
pclose(popen('start /B php "your script.php" > "my result.txt" 2> "error.log"' , 'r')); works.
But now let's assume that you do not have php in your path. This does not work:
pclose(popen('start /B "C:\Program Files (x86)\PHP\php.exe" "your script.php" > "my result.txt" 2> "error.log"' , 'r'));
Why? Because cmd only preserves the double quotes if there is not one of: &<>()@^| special characters between the two double-quote characters.
Double quotes between double quotes are preserved however if /S is used, in that case only the two outer double quotes are removed. So add two double quotes surrounding your command and add the default cmd /C plus the extra /S like:
pclose(popen('start /B cmd /S /C ""C:\Program Files (x86)\PHP\php.exe" "your script.php" > "my result.txt" 2> "error.log""' , 'r'));
__________________
مرا سر نهان گر شود زير سنگ -- از آن به كه نامم بر آيد به ننگ
به نام نكو گر بميــرم رواست -- مرا نام بايد كه تن مرگ راست
|
جای تبلیغات شما اینجا خالیست با ما تماس بگیرید
|
|