博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何获取cURL以不显示进度栏?
阅读量:2289 次
发布时间:2019-05-09

本文共 2420 字,大约阅读时间需要 8 分钟。

本文翻译自:

I'm trying to use cURL in a script and get it to not show the progress bar. 我正在尝试在脚本中使用cURL,并使其显示进度栏。

I've tried the -s , -silent , -S , and -quiet options, but none of them work. 我尝试了-s-silent-S-quiet选项,但是它们都不起作用。

Here's a typical command I've tried: 这是我尝试过的典型命令:

curl -s http://google.com > temp.html

I only get the progress bar when pushing it to a file, so curl -s http://google.com doesn't have a progress bar, but curl -s http://google.com > temp.html does. 我只在将进度条推送到文件时才看到进度条,所以curl -s http://google.com没有进度条,但是curl -s http://google.com > temp.html有。


#1楼

参考:


#2楼

I found that with curl 7.18.2 the download progress bar is not hidden with: 我发现使用curl 7.18.2时,下载进度条没有隐藏:

curl -s http://google.com > temp.html

but it is with: 但它具有:

curl -ss http://google.com > temp.html

#3楼

In curl version 7.22.0 on Ubuntu and 7.24.0 on OSX the solution to not show progress but to show errors is to use both -s ( --silent ) and -S ( --show-error ) like so: 在Ubuntu的curl版本7.22.0和OSX的7.24.0版本中, 不显示进度显示错误的解决方案是同时使用-s (-- --silent )和-S (-- --show-error ),如下所示:

curl -sS http://google.com > temp.html

This works for both redirected output > /some/file , piped output | less 这对于重定向输出> /some/file ,管道输出| less | less and outputting directly to the terminal for me. | less ,直接为我输出到终端。


#4楼

Some time ago wrote a simple script to do the scrapping for searching for example specific versions of jdk installed: 前段时间写了一个简单的脚本来抓取搜索安装的特定版本的jdk的示例:

#!/bin/bashREPO_TAG_URL=$1SEARCH=`curl -s $REPO_TAG_URL`NEXT_PAGE=`echo $SEARCH | jq -r .next`echo $SEARCH | jq '.results[].name'while [[ $NEXT_PAGE != 'null' ]]; do    SEARCH=`curl -s $NEXT_PAGE`    NEXT_PAGE=`echo $SEARCH | jq -r .next`    echo $SEARCH | jq '.results[].name'doneecho "Thats all folks"

You use it like this: ./script.sh https://registry.hub.docker.com/v2/repositories/library/tomcat/tags/ 您可以这样使用它: ./script.sh https://registry.hub.docker.com/v2/repositories/library/tomcat/tags/


#5楼

Not sure why it's doing that. 不知道为什么要这么做。 Try -s with the -o option to set the output file instead of > . 使用-o选项尝试-s来设置输出文件,而不是>


#6楼

curl -s http://google.com > temp.html

works for curl version 7.19.5 on Ubuntu 9.10 (no progress bar). 适用于Ubuntu 9.10上的curl版本7.19.5(无进度条)。 But if for some reason that does not work on your platform, you could always redirect stderr to /dev/null: 但是,如果由于某种原因在您的平台上不起作用,则可以始终将stderr重定向到/ dev / null:

curl  http://google.com 2>/dev/null > temp.html

转载地址:http://nscnb.baihongyu.com/

你可能感兴趣的文章
网络游戏线上活动的类型及特点(二)
查看>>
sleeping-to-save-cpu
查看>>
键盘符号英语读法
查看>>
[转]char_traits
查看>>
[转载] 人生三重境界
查看>>
[转载]学习时注意思考方法
查看>>
C10K问题
查看>>
STL 线程安全性
查看>>
Writing Reentrant and Thread-Safe Code(编写可重入和线程安全的代码)
查看>>
可重入性
查看>>
无闪烁刷屏技术的实现
查看>>
Crazybit开发手记(一):设计之数据结构和算法的分离
查看>>
Windows消息
查看>>
Windows线程及同步机制
查看>>
CImage类
查看>>
FreeMind 0.80 正式版已经出来了
查看>>
虚拟化技术比较 PV HVM
查看>>
无法捕获的C++异常
查看>>
一台机器配置多个ip地址时被动响应和主动发起的源ip选择
查看>>
E1,T1, PRI, Trunk
查看>>