PHP proc_open işlevini kullanma

1 Cevap php

I am trying to execute a TCL script from PHP. I am using PHP's proc_open for the communication .But I am unable to get the result from the tcl script . Can someone go through the code and let me know where I am going wrong ?

PHP kodu

<?php
$app = 'tclsh84.exe';

$spec = array(array("pipe", "r"), array("pipe", "w"), array("pipe", "w"));

$process = proc_open($app, $spec, $pipes);

if (is_resource($process)) 
{

    fwrite($pipes[0], 'source sum.tcl ');
    fwrite($pipes[0], 'tclsh test.tcl ');
    fclose($pipes[0]);

  echo stream_get_contents($pipes[1]);
  fclose($pipes[1]);

 //   echo fread($pipes[1],1024).'<hr>';


   proc_close($process);
}
?>


//sum.tcl 
proc sum {arg1 arg2} {
    set x [expr {$arg1 + $arg2}];
    return $x
}

//test.tcl
puts " the sum is [sum 10 9 ] "

1 Cevap

Sen (fwrite($pipes[0], "source sum.tcl\n")), bu neden olabilir uygulamaya satırsonlarını geçen değil mi? Aksi takdirde işlev çağrıları tüm dönüş değerleri kontrol ettiğinizden emin olun. Ilk fwrite () başarısız olursa, örneğin, erken başarısız gerekir.