Çalışma dizini proc_open

2 Cevap

I have a PHP script at the following location C:\wamp\www\tcl\bin\

Ben bir tarayıcı aracılığıyla aynı erişim.Ancak (http://localhost/tcl/bin/xxx.php

PHP komut dosyası. Ben bir proc_open yapıyorum

$app = 'C:/wamp/www/tcl/bin/tclsh84.exe';
$process = proc_open($app, $descriptorspec, $pipes);

if i give the full path it works , but if I just give tclsh84.exe it does not work . Although the PHP manual states if you don't give 4th parameter of proc_open (CWD) it takes the directory of the currently executing process.

Bu windows ve linux hem de çalışmak gerekiyor gibi tcl yürütülebilir yolunu kodlamalısınız olamaz gibi Birisi bana rehberlik eder.

Regards, Mithun

2 Cevap

Eğer tclsh84.exe için tam yolunu kullanırsanız çalışır söylüyorlar. Yani, bir çözüm olduğunu tam yolunu bulmak ve proc_open için çağrı kullanmak için olabilir.


If you know your tclsh84.exe is in the directory in which your PHP script is, you could use something based on dirname and __FILE__ ; a bit like this, I suppose :

$dir = dirname(__FILE__);
var_dump($dir);   // directory in which the current PHP script is in

$path = $dir . DIRECTORY_SEPARATOR . 'tclsh84.exe';
var_dump($path);

Ben kullanıyorum PHP komut düşünüyor /home/squale/developpement/tests/temp/temp.php, ben elde ediyorum:

string '/home/squale/developpement/tests/temp' (length=37)
string '/home/squale/developpement/tests/temp/tclsh84.exe' (length=49)

Ve gerekirse, aşağı gitmek için dizinleri adlarını kullanın, sonra dizinleri ağaç kadar gitmek '..' kullanabilir ve.


Another solution might be to make sure that the program you are trying to execute is in your PATH environment variables -- but if it's a program that's used only by your application, it doesn't make much sense to modify your PATH, I guess...

Ben yürütme işlemi tarafından size PHP yolunu değil, script yolu anlamına gelir inanıyoruz. Aksi takdirde bir yapılandırma dosyasında tanımlamak kullanabilirsiniz, bu zarar vermez.