问题
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 ?
回答1:
Perhaps curl's -N / --no-buffer option will help you?
来源:https://stackoverflow.com/questions/30070818/curl-live-output-cli