Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL live output CLI

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 ?

like image 754
Doubidou Avatar asked Oct 23 '25 06:10

Doubidou


1 Answers

Perhaps curl's -N / --no-buffer option will help you?

like image 108
Daniel Stenberg Avatar answered Oct 25 '25 23:10

Daniel Stenberg