I try to have a "live output" of a web page in a shell script ; to explain, a little example :
With this "localhost/index.php" like this:
<?php
header('Content-type: text/html; charset=utf-8');
echo 'Start<br />'.PHP_EOL;
for( $i = 0 ; $i < 10 ; $i++ )
{
echo '.';
flush();ob_flush();
sleep(1);
}
echo PHP_EOL.'<br />End';
?>
I want to write a shell script which permit to have the "dots" on the screen that appears each second.
If I try this :
#!/bin/bash
curl 'localhost/index.php'
It shows the output only after each breaklines... Not after each update (or "echo" in PHP script) If a pipe this, all output will be show at the end :/
Is there a way to have the real time output, like in a browser ?
Perhaps curl's -N / --no-buffer option will help you?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With