Есть два хумана, оба установлены на одной машине.
Задача из одного хумана запустить скрипт в другом.
Для реализации использую curl
Обычные команды, типа navigate исполняются отлично, но вот при Application.run_script происходит следующее - на управляющем хумане curl как бы "зависает" и чего-то ждет, а на управляемом хумане видно что скрипт запустился и опять же чего-то ждет. И ждать могут очень долго и не завершаются вообще.
Если остановить скрипт на управляемом хумане - то curl возвращает cURL Error: Recv failure: Connection was reset
В управляемом скрипте, для эксперимента, полезного кода вообще нет, только app->quit
строка вызова -
h--p://localhost:7100/Application.run_script?path=C%3A%5Cxweb35%5C7100%5CMy+Scripts%5CMyScript.php
Вопрос - что я делаю не так?
Хуман - 4.9.35
Win10 x64
Код на управляющем хумане:
Код: Выделить всё
<?php
$xhe_host = "127.0.0.1:7020";
// The following code is required to properly run XWeb Human Emulator
require("../Templates/xweb_human_emulator.php");
$url = "http://localhost:7100/Application.run_script";
$params = array (
'path' => 'C:\\xweb35\\7100\\My Scripts\\MyScript.php'
);
print_r(requester($url, $params, $requestType="get", $isJson=0, $fileName=""));
function requester($url, $params, $requestType="get", $isJson=0, $fileName="") {
$answer = array();
$answer["answer"] = "";
$answer["info"] = "";
$answer["error"] = "";
// Create a CURLFile object - procedural method
//$cfile = curl_file_create('D:\\img\\down-bw\\7010-1.bmp','image/bmp','testpic'); // try adding
if (file_exists($fileName)) {
$cfile = curl_file_create($fileName);
$params = array (
'file' => $cfile,
);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ($requestType == "post"){
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-REQUESTED-WITH: XMLHttpRequest'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
} else {
$strParams = "";
foreach ($params as $key=>$param) {
$strParams .= $key."=".urlencode($param)."&";
}
$strParams = "?".$strParams;
curl_setopt($ch, CURLOPT_URL, $url.$strParams);
echo $url.$strParams."<br>";
}
$output = curl_exec($ch);
if ($output !== false) {
if ($isJson == 1) {
$answer["answer"] = json_decode($output, true);
} else {
$answer["answer"] = $output;
}
$answer["info"] = curl_getinfo($ch);
} else {
$answer["error"] = curl_error($ch);
echo "cURL Error: " . curl_error($ch);
}
curl_close($ch);
return $answer;
}
// Quit
$app->quit();
?>
Код: Выделить всё
<?php
$xhe_host = "127.0.0.1:7100";
// The following code is required to properly run XWeb Human Emulator
require("../Templates/xweb_human_emulator.php");
// Quit
$app->quit();
?>