shell常用命令之curl: -w,–write-out參數詳解

顧名思義,write-out的作用就是輸出點什么。curl的-w參數用于在一次完整且成功的操作后輸出指定格式的內容到標準輸出。

輸出格式由普通字符串和任意數量的變量組成,輸出變量需要按照%{variable_name}的格式,如果需要輸出%,double一下即可,即%%,同時,\n是換行,\r是回車,\t是TAB。curl會用合適的值來替代輸出格式中的變量,所有可用變量如下:

url_effective 最終獲取的url地址,尤其是當你指定給curl的地址存在301跳轉,且通過-L繼續追蹤的情形。

http_code http狀態碼,如200成功,301轉向,404未找到,500服務器錯誤等。(The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer. In 7.18.2 the alias response_code was added to show the same info.)

http_connect The numerical code that was found in the last response (from a proxy) to a curl CONNECT request. (Added in 7.12.4)

time_total 總時間,按秒計。精確到小數點后三位。 (The total time, in seconds, that the full operation lasted. The time will be displayed with millisecond resolution.)

time_namelookup DNS解析時間,從請求開始到DNS解析完畢所用時間。(The time, in seconds, it took from the start until the name resolving was completed.)

time_connect 連 接時間,從開始到建立TCP連接完成所用時間,包括前邊DNS解析時間,如果需要單純的得到連接時間,用這個time_connect時間減去前邊 time_namelookup時間。以下同理,不再贅述。(The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.)

time_appconnect 連接建立完成時間,如SSL/SSH等建立連接或者完成三次握手時間。(The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0))

time_pretransfer 從開始到準備傳輸的時間。(The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.)

time_redirect 重定向時間,包括到最后一次傳輸前的幾次重定向的DNS解析,連接,預傳輸,傳輸時間。(The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3))

time_starttransfer 開始傳輸時間。在發出請求之后,Web 服務器返回數據的第一個字節所用的時間(The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result.)

size_download 下載大小。(The total amount of bytes that were downloaded.)

size_upload 上傳大小。(The total amount of bytes that were uploaded.)

size_header ?下載的header的大小(The total amount of bytes of the downloaded headers.)

size_request 請求的大小。(The total amount of bytes that were sent in the HTTP request.)

speed_download 下載速度,單位-字節每秒。(The average download speed that curl measured for the complete download. Bytes per second.)

speed_upload 上傳速度,單位-字節每秒。(The average upload speed that curl measured for the complete upload. Bytes per second.)

content_type 就是content-Type,不用多說了,這是一個訪問我博客首頁返回的結果示例(text/html; charset=UTF-8);(The Content-Type of the requested document, if there was any.)

num_connects Number of new connects made in the recent transfer. (Added in 7.12.3)

num_redirects Number of redirects that were followed in the request. (Added in 7.12.3)

redirect_url When a HTTP request was made without -L to follow redirects, this variable will show the actual URL a redirect would take you to. (Added in 7.18.2)

ftp_entry_path The initial path libcurl ended up in when logging on to the remote FTP server. (Added in 7.15.4)

ssl_verify_result ssl認證結果,返回0表示認證成功。( The result of the SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.19.0))

注意:

1、若多次使用-w參數,按最后一個的格式輸出。

2、在使用上面變量的時候,注意看后面小括號中的 Added in XXX,這個表示支持該變量curl所需的最低版本,查看curl版本使用curl -V。如果版本不夠,curl會提示類似下面的錯誤。

curl: unknown –write-out variable: ‘redirect_url’


curl -w用法一例

檢 查一批URL的HTTP狀態:cat url.txt|while read line; do curl -I $line -m 5 –connect-timeout 5 -o /dev/null -s -w “$line “%{http_code}”\n”; done>ok.txt

?

?

?

原文地址:http://seofangfa.com/shell/curl-w-write-out.html

?

轉載于:https://www.cnblogs.com/shell-blog/p/5466905.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/255375.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/255375.shtml
英文地址,請注明出處:http://en.pswp.cn/news/255375.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Val編程-速度因子

機械手臂在一個三個基本指令(movel,movej,movec)指令中有下面基本參數進行配置。 1. Frame toolField; Tcp的值2. Frame frameField;用戶坐標系的值3. MoveType absRelField;絕對運動與相對運動4. Config configField;姿態5. BlendType blendTypeField;倒…

Node.js學習之路24——Express框架的app對象

1.express() 基于Node.js平臺,快速、開放、極簡的web開發框架。創建一個Express應用.express()是一個由express模塊導出的入口top-level函數.const express require(express); let app express(); 1.1 靜態資源管理 express.static(root, [options]) express.stat…

【pyqt5學習】——對話框QDialog學習(QMessageBox、QColorDialog、QFIleDialog、QFontDialog、QInputDialog)

目錄 1、對話框QDialog類別 2、通用對話框 ?編輯 3、消息對話框QMessageBox() 1)消息對話框QMessageBox類型 2)案例 ?編輯 4、輸入對話框QInputDialog 1) 類型 2)案例 5、字體格式對話框QFontDialog 6、顏色對話框QColorDialog 1&…

使用 Mesos 管理虛擬機

摘要 為了滿足渲染、基因測序等計算密集型服務的需求,UCloud 推出了“計算工廠”產品,讓用戶可以快速創建大量的計算資源(虛擬機)。該產品的背后,是一套基于 Mesos 的計算資源管理系統。本文簡要介紹該系統的結構、Mes…

Swift數據類型_整型和浮點型

//swift中的整型和浮點型/***//類型推斷整數是Int 浮點數是Double ,日常使用需要注意不能越界,存儲時間毫秒數 英雄經驗數等等之類內容容易越界整型大多數情況下,你不需要在代碼中指定哪種整型。Swift提供了一種額外的整型,Int類型Java中的long型&#x…

Val編程-套接字

套接字的介紹:http://zh.wikipedia.org/wiki/Berkeley%E5%A5%97%E6%8E%A5%E5%AD%97 主要分為客戶端和服務器。客戶端一般是需要主動去鏈接,需要配置服務器的IP和端口。服務器是被動響應,需要打開相應的端口。端口一般不推薦使用系統端口和常用…

【pyqt5學習】——Qpainter控件學習(文本、圖像、各種圖形)

目錄 1、作用及應用步驟 2、繪制文本drawText() 3、像素級別繪制點(正弦曲線為例) 4、繪制不同樣式的直線 5、繪制弧形、圓形、扇形、圖像等 6、畫刷填充區域QBrush 1、作用及應用步驟 QPainter是一個用于繪制的類,該類可以用于繪制&…

反向代理與Real-IP和X-Forwarded-For(轉)

如下圖所示,客戶端通過Nginx Proxy1 和 Nginx Proxy2 兩層反向代理才訪問到具體服務Nginx Backend(或如Tomcat服務)。那Nginx Backend如何才能拿到真實客戶端IP呢? 接下來我們來看看如何才能獲取到客戶端真實IP。 場景1  場景1是…

Android studio打開之后 cannot load project: java.lang.NUllpointerException

參考來源:http://bbs.csdn.net/topics/391014393 關閉網絡,重新打開Android studio就好了。(但是原因不清楚是為什么?) Internal error. Please report to http://code.google.com/p/android/issuescom.intellij.ide.p…

Val編程-任務編程

不同任務之間可以通過一個標志符來實現互斥事件。 程序代碼&#xff1a; Task2 <span style"font-size:12px;">beginwhile truewait(bTaskFlag)cls()gotoxy(1,1)put("這是Task2")gotoxy(1,2)if bTaskFlagput("BFlag:true ")elseput(&…

【pyqt5學習】——拖拽功能(DragDrop)、剪切板(QApplication.clipboard)

目錄 1、拖拽功能&#xff08;Drag&Drop&#xff09; 2、剪切板&#xff08;QApplication.clipboard&#xff09; 1、拖拽功能&#xff08;Drag&Drop&#xff09; 選擇文本輸入框中的文本&#xff0c;移動到下拉框中自動添加步驟&#xff1a; 1、將文本輸入框設置為可…

oracle12c之 控制pdb中sga 與 pga 內存使用

Memory Management using Resource Manager Oracle數據庫資源管理器(資源管理器)現在可以在多租戶容器數據庫(CDB)中管理可插入數據庫(PDBs)之間的內存使用。這一特性有助于在CDB中維護所有PDBs的性能&#xff0c;確保所有的PDBs都不會占用更多資源&#xff0c;從而導致其他PDB…

[LeetCode] 21. Merge Two Sorted Lists ☆

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 解法&#xff1a; 新建一個鏈表&#xff0c;依次比較兩個鏈表的頭元素&#xff0c;把較小的移到新鏈表中&#xff0c;直到有…

Val編程-特殊函數使用

Waitendmove()和$Waitendmove()使用心得 這是兩個部分&#xff0c;程序運行部分和運動堆棧部分&#xff0c;waitendmove是兩個部分進行交互的一個函數。 一般情況下waitendmove()速度會降到0&#xff0c;相當于blend等于off. 代碼&#xff1a; begincls()userPage()title("…

Redis的五種數據結構

Redis支持持久化只是它的一件武器&#xff0c;它提供了多達5種數據存儲方式&#xff1a; 一 string&#xff08;字符串&#xff09; string是最簡單的類型&#xff0c;你可以理解成與Memcached一模一樣的類型&#xff0c;一個key對應一個value&#xff0c;其上支持的操作與Mem…

【pyqt5學習】——QDateTimeEdit控件學習

目錄 1、同時顯示日期時間QDateTime 2、只顯示日期QDate 3、只顯示時間QTime 4、設置顯示的格式setDisplayFormat 5、 QDateTimeEdit常用信號 6、實例 1、同時顯示日期時間QDateTime # 同時顯示日期時間dateTimeEdit1 QDateTimeEdit()dateTimeEdit2 QDateTimeEdit(QDat…

復選框做成單選效果

function zlClick($id){ var eles document.getElementById($id).children; var srcEle event.srcElement; for(var i0;i<eles.length;i){ if(srcEle.checked){ if(eles[i].value!srcEle.value){ eles[i].checkedfalse; } } } } 技術領域可信計算 其他 申請日 200020012…

013. MVC5過濾器

微軟提供了4中過濾器: 1.Action過濾器: 在Action方法執行之前和Action方法執行之后, 會執行此過濾器中的代碼. 比如在執行public ActionResult Index()方法之前或之后; 也可以說是在方法執行前或執行后; 接口: IactionFilter 抽象類名: ActionFilterAttribute 添加一個實現…

Val編程-讀取漢字

Val編程-讀取漢字 Val編程中&#xff0c;對于漢字的讀取不是很友好&#xff0c;利用fileget直接讀取記事本產生的文件字符串會導致亂碼的產生。因為Val只支持使用utf-8進行編碼&#xff0c;因此讀取的文本需要進行utf-8格式轉換。 在GBK中&#xff0c;漢字占兩個字節。并且…

【pyqt5學習】——菜單欄(QMenu())、工具欄QToolBar學習

目錄 1、菜單欄&#xff08;QMenu()&#xff09;——一般在窗口頂部 1&#xff09;創建菜單欄步驟 2&#xff09;信號與方法 3&#xff09;實操 2、工具欄——一般在菜單欄下方 1&#xff09;創建步驟 2&#xff09;方法與信號 信號&#xff1a; 方法&#xff1a; 3&am…