Php 从Expect脚本捕获特定输出

Php 从Expect脚本捕获特定输出,php,telnet,expect,tasklist,Php,Telnet,Expect,Tasklist,我正在尝试使用Expect确定应用程序RA-POS是否在Mac远程Windows XP上运行。我通过一个PHP页面发送此消息,希望返回该页面上的结果作为初始测试。不幸的是,当我同时运行它们时,结果是命令行提示符,而不是程序是否正在运行的实际信息。最后,我想创建一个条件,其中expect根据RA-POS是否正在运行返回值1或0,然后继续执行另一个脚本或停止进程 这是我的期望 #!/usr/bin/expect -d set login "administrator" set password "

我正在尝试使用Expect确定应用程序RA-POS是否在Mac远程Windows XP上运行。我通过一个PHP页面发送此消息,希望返回该页面上的结果作为初始测试。不幸的是,当我同时运行它们时,结果是命令行提示符,而不是程序是否正在运行的实际信息。最后,我想创建一个条件,其中expect根据RA-POS是否正在运行返回值1或0,然后继续执行另一个脚本或停止进程

这是我的期望

#!/usr/bin/expect -d

set login "administrator"
set password "password"
set machineid [lindex $argv 0]
set portid [lindex $argv 1]
set cmdprompt "C:\Documents and Settings\Administrator>"
set output $expect_out(0,string)

spawn telnet -l administrator $machineid.noerrpole.com $portid
expect "password:"
send "$password\r"
expect "$cmdprompt"
send "tasklist /nh /FI \"IMAGENAME eq RA-POS.exe\"\r"
expect -re "(INFO:*)\r"
send_user "$expect_out(0,string)\n"
expect "$cmdprompt"
send "exit\r"
interact
这里是PHP

<?php
echo "<html>";
echo "<head>";
echo "<title>Turn off Windows Automatic Update</title>";
echo "</head>";
echo "<body>";
echo '<img src="NOERRlogofinal.jpg">';
echo "<br>";
echo "<br>";
echo "<pre>";

$portoffset = 1000 * $_POST["station"];
$port = 21023 + $portoffset;
$mall = $_POST["mall"];

$cmd = "/usr/bin/expect /home/dev/www/RAPOStest " . $_POST["mall"] . " " . $port;


echo "Running " . $cmd;

$retval = system($cmd);
echo "<br>";
echo "sss <br>";
echo "$retval";
echo "sss <br>";




echo "</pre>";

echo "<br>Your POS has been updated " . $_POST["mall"];
echo "<br>";
echo "<br>";
echo "</body>";
echo "</html>";

您的
echo
s中缺少大量引用。所有的
echo
调用都应该有引号,除非
echo
使用了变量。网站的新功能抱歉,所有引号都在那里,代码已经更新。
Running /usr/bin/expect /home/dev/www/RAPOStest NPCO-CP 22023spawn telnet -l administrator NPCO-CP.noerrpole.com 22023
Trying 166.161.172.106...

Connected to NPCO-CP.noerrpole.com.

Escape character is '^]'.

Welcome to Microsoft Telnet Service 


password: 

*===============================================================
Welcome to Microsoft Telnet Server.
*===============================================================
C:\Documents and Settings\Administrator>tasklist /nh /FI "IMAGENAME eq RA-POS.exe"
INFO: No tasks running with the specified criteria.

C:\Documents and Settings\Administrator>password:

sss 
C:\Documents and Settings\Administrator>password:sss 

Your POS has been updated NPCO-CP