cURL实时输出CLI [英] cURL live output CLI

查看:108
本文介绍了cURL实时输出CLI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在shell脚本中提供网页的实时输出";解释一下,一个小例子:

I try to have a "live output" of a web page in a shell script ; to explain, a little example :

使用这样的"localhost/index.php":

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';
?>

我想编写一个shell脚本,该脚本允许每秒出现在屏幕上的点".

I want to write a shell script which permit to have the "dots" on the screen that appears each second.

如果我尝试这样做:

#!/bin/bash
curl 'localhost/index.php'

仅在每个换行符之后显示输出...在每次更新后不显示(或在PHP脚本中为"echo") 如果是管道,则所有输出将显示在末尾:/

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 ?

推荐答案

也许curl的- N/--no-buffer 选项会帮助您吗?

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

这篇关于cURL实时输出CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆