ウェブページを取得して、ローカルファイルに名前を付けて保存: curl -o thatpage.html http://www.netscape.com/
curl によるデータのポストは簡単である。 -d データ オプションを用いる。 ポストデータは URL エンコードしておかなければならない。 簡単な name と phone のポスト: curl -d "name=Rafael%20Sagula&phone=3320780" http://www.where.com/guest.cgi
-O だと、リクエスト先の名前でファイルを保存します。
$ curl -LI mazgi.com -o /dev/null -w '%{http_code}\n' -s
-Lがリダイレクトに対応、-Oがファイルに保存(指定しないと標準出力です。) $ curl -L -O [URL]
% curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"user":{"first_name":"first name", ...}}' http://localhost:3000/api/1/users
# NTLM認証もしくはDigest認証のかかったサイトにアクセス(--anyauth) $ curl --anyauth --user USERID:PASSWORD http://www.example.com/
curl コマンド、ちょくちょく使うけどオプション忘れてまう
インターネットに出られるけれど、インターネットから入ってこれないサーバの死活監視を、お気軽にしたい。
curl -L --output /dev/null --silent --show-error --write-out 'lookup: %{time_namelookup}\nconnect: %{time_connect}\nappconnect: %{time_appconnect}\npretransfer: %{time_pretransfer}\nredirect: %{time_redirect}\nstarttransfer: %{time_starttransfer}\ntotal: %{time_total}\n' 'google.com'