Ben proc_open (gerekli çift yönlü destek) ile bir c + + / python dosyası için bir arama yapmak için çalışıyorum.
Bazı on-line araştırma yaptıktan sonra bu kodu oluşturulan bulunamadı: (Ben ilk hatasından sonra ben de python çalıştı, c + + ile denedim)
PHP:
<?php
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("file", "error-output.txt", "a")
);
$process = proc_open('new.exe', $descriptorspec, $pipes);
$input = 20;
$exp = 2;
if (is_resource($process)) {
print fgets($pipes[1]);
fwrite($pipes[0], $input);
print fgets($pipes[1]);
fwrite($pipes[0], $exp);
print fgets($pipes[1]);
fclose($pipes[1]);
fclose($pipes[0]);
$return_value = proc_close($process);
echo "command returned $return_value\n";
} else {
echo "No resource availeble";
}
?>
C + +:
#include <iostream>
using namespace std;
int main () {
// Get variables from php
cout << "input" << endl;
cin << input
cout << "exponent" << endl;
cin << exp
// Process variables
int answer = input + exp;
// Return variables
cout << answer;
// End c++ script
return 0;
}
Python:
print 'enter input'
inp = raw_input()
print 'enter exponent'
exp = raw_input()
ant = inp + exp
print ant
Ama ne yazık ki yeterince aynı hata ile başarısız tuttu: file iç ya da dış komut, program ya da toplu iş dosyası olarak tanınmıyor.
Bazı ekstra bilgiler:
I used Wamp with PHP 5.3.0
The return value I get from proc_close()
= 1