質問

I was trying to use php file to run a test and get the result. The content in PHP is shown as follows:

<html>
<body style="background-color:#CCCCFF;">
<h1>Result of SimplePolicyTest:</h1>
<?php
$filename='results_'.date('Y-m-d_H-i-s').'_simple-policy.php';
$path='/var/www/qa/automation/results/';
$destination=$path.$filename;
$cmd='/var/www/selenium/projects/QA\ Automation/grid/./SimplePolicyTest | tee -a '.$destination;
echo $cmd;
system($cmd);
?>
</body>
</html>

What's inside the bash file is to initiate a selenium test. But the result is I got the test result after the test is done on the page. However, the required file is not found where it is supposed to be. Also I'm suing system right now. Is there any way to make the output on the pager real time?

役に立ちましたか?

解決

Few suggestions:

  1. Did you want INCLUDE the output result php file in your main file?
  2. You may have a look at popen function in php. That function allows you to capture the stdout of the command directly. No need to tee it to another file & then include it.
  3. If you have access to bash on the system, try running the command directly on bash, to verify that it indeed outputs something.
  4. Try installing php locally & debug with easier commands, to see if | can be used in system.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top