Open8

Linux Knowledge

ファイルに出力する時、unixtimeを含める方法

for i in {1..200}; do echo $i; sleep 0.5; curl --insecure --request POST \
  --url 'https://account.google.com/login'\
	-w "http_code: %{http_code}\ntime_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_pretransfer: %{time_pretransfer}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" > Desktop/login_curl_$(date +%s).txt \
  --data-raw 'came_from=%2F&email=gmail&password=gmail&form.submitted=Log+In' \
  --compressed& done

res=$?
if test "$res" != "0"; then
   echo "the curl command failed with: $res"
fi
-w @curl.out で指定すれば次のような出力が得られます。-w @- と、ファイル名を「-」にすれば標準入力から渡すこともできます

$ curl -so /dev/null -w @curl.out https://www.google.com/
content_type:       text/html; charset=ISO-8859-1
filename_effective: /dev/null
ftp_entry_path:
http_code:          200
http_connect:       000
local_ip:           172.26.45.140
local_port:         43760
num_connects:       1
num_redirects:      0
redirect_url:
remote_ip:          172.217.25.228
remote_port:        443
size_download:      12618
size_header:        772
size_request:       78
size_upload:        0
speed_download:     98443.000
speed_upload:       0.000
ssl_verify_result:  0
time_appconnect:    0.052
time_connect:       0.004
time_namelookup:    0.001
time_pretransfer:   0.052
time_redirect:      0.000
time_starttransfer: 0.128
time_total:         0.128
url_effective:      https://www.google.com/
作成者以外のコメントは許可されていません