html - Autoscroll in bash script output called from PHP -


i have php script prints output of bash script (actually expect script), looks this:

<?php  ob_implicit_flush(true); ob_end_flush();  $cmd = "./expect_script.sh";  $descriptorspec = array(    0 => array("pipe", "r"),    1 => array("pipe", "w"),    2 => array("pipe", "w")  );  $process = proc_open($cmd, $descriptorspec, $pipes, realpath('./'), array());  echo '<pre>'; if (is_resource($process)) {     while ($s = fgets($pipes[1])) {         print $s;      } } echo '</pre>'; ?> 

so wanted real time output automatic scroll @ end of page every new line appearance , found this: printing process output in realtime

then added proposed html code script follows:

<html><head> <script language="javascript"> var int = self.setinterval("window.scrollby(0,1000);", 200); </script> </head> <body>  <?php  ob_implicit_flush(true); ob_end_flush();  $cmd = "./expect_script.sh";  $descriptorspec = array(    0 => array("pipe", "r"),    1 => array("pipe", "w"),    2 => array("pipe", "w")  );  $process = proc_open($cmd, $descriptorspec, $pipes, realpath('./'), array());  echo '<pre>'; if (is_resource($process)) {     while ($s = fgets($pipes[1])) {         print $s;      } } echo '</pre>'; ?>  </body> </html> 

however, when script finishes web browser won't let me browse top of page because still scrolling bottom.

how shall avoid can browse once script finished?

you using setinterval repeat task , never ask stop that.

you need stop setinterval repeating , @ end of php code add :

echo '</pre>'; echo '<script language="javascript">self.clearinterval(int);</script>'; 

also need close proc process :

if (is_resource($process)) {     while ($s = fgets($pipes[1])) {         print $s;      }     proc_close($process); } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -