我试图从PHP执行TCL脚本。我正在使用PHP的proc_open进行通信。但我无法从tcl脚本中获得结果。 有人可以通过代码,让我知道我要去哪里错了吗?在PHP中使用proc_open函数
PHP代码
<?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 ] "
你在错误管道上看到了什么? – 2009-08-24 17:54:20
“tclsh”不是Tcl命令。你的意思是“source test.tcl”吗? – 2009-08-24 17:54:53
我没有看到任何错误。我只是在浏览器上看到一个空白页面。 tclsh是一个命令,它用来执行一个tcl文件。 – Vidya 2009-08-25 00:56:58