📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)
細 文字列「__FORCETOC__」を「{{#seo: |title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki |keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板 |description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This pag… |
|||
| (同じ利用者による、間の8版が非表示) | |||
| 24行目: | 24行目: | ||
* プロキシを経由したリクエスト | * プロキシを経由したリクエスト | ||
*: プロキシサーバを経由してリクエストを送信することができる。 | *: プロキシサーバを経由してリクエストを送信することができる。 | ||
<br><br> | |||
== curlのインストール == | |||
多くのLinuxディストリビューションでは、標準でcurlがインストールされている。<br> | |||
<br> | |||
==== パッケージ管理システムからインストール ==== | |||
# RHEL | |||
sudo dnf install curl | |||
# SUSE | |||
sudo zypper install curl | |||
<br> | |||
==== ソースコードからインストール ==== | |||
もし、別途インストールする必要がある場合、ソースコードからcurlをインストールする。<br> | |||
<br> | |||
curlのビルドに必要なライブラリをインストールする。<br> | |||
# SUSE | |||
sudo zypper install make cmake gcc perl libopenssl-devel libopenssl-1_1-devel libzstd-devel c-ares-devel libpsl-devel \ | |||
libssh-devel # オプション : libSSHライブラリを使用する場合 | |||
libssh2-devel # オプション : libSSH2ライブラリを使用する場合 | |||
libgnutls-devel # オプション : GNU TLSライブラリを使用する場合 | |||
mbedtls-devel # オプション : Mbed TLSライブラリを使用する場合 | |||
libnghttp2-devel # オプション : NGHTTPライブラリを使用する場合 | |||
libheimdal-devel # オプション : GSSを使用する場合 | |||
<br> | |||
[https://curl.se/download.html curlの公式Webサイト]、または、[https://github.com/curl/curl curlのGithub]にアクセスして、ソースコードをダウンロードする。<br> | |||
ダウンロードしたファイルを解凍する。<br> | |||
tar xf curl-<バージョン>.tar.xz | |||
cd curl-<バージョン> | |||
<br> | |||
curlをビルドおよびインストールする。<br> | |||
mkdir build && cd build | |||
# Configureスクリプトを使用する場合 | |||
../configure --prefix=<curlのインストールディレクトリ> \ | |||
--with-openssl \ | |||
--with-gnutls # オプション : GNUTLSを使用する場合 | |||
--with-wolfssl # オプション : WolfSSLを使用する場合 | |||
# CMakeを使用する場合 | |||
cmake .. -DCMAKE_BUILD_TYPE=Release \ | |||
-DCMAKE_INSTALL_PREFIX=<CURLのインストールディレクトリ> \ | |||
-DENABLE_ARES=ON \ # C Aresを有効にする場合 | |||
-DCURL_USE_GNUTLS=ON \ # GNU TLSを有効にする場合 | |||
-DCURL_USE_MBEDTLS=ON \ # Mbed TLSを有効にする場合 | |||
-DCURL_USE_WOLFSSL=ON \ # Wolf SSLを有効にする場合 | |||
-DUSE_NGHTTP2=ON \ # NG Httpを有効にする場合 | |||
-DCURL_USE_GSSAPI=ON # GSS APIを有効にする場合 | |||
make -j $(nproc) | |||
make install | |||
<br> | |||
~/.profileファイル等に、環境変数<code>PATH</code>を追記する。<br> | |||
vi ~/.profile | |||
<br> | |||
# ~/.profileファイル | |||
export PATH="/<curlのインストールディレクトリ>/bin:$PATH" | |||
<br><br> | <br><br> | ||
| 56行目: | 114行目: | ||
== curlコマンドのオプション == | == curlコマンドのオプション == | ||
<center> | |||
{| class="wikitable" | style="background-color:#fefefe;" | |||
|- | |||
! style="background-color:#66CCFF;" | オプション | |||
! style="background-color:#66CCFF;" | 説明 | |||
! style="background-color:#66CCFF;" | 実行例 | |||
|- | |||
| -A<br>--user-agent || UAを指定する。 || curl -A "Mozilla/5.0" https://example.com | |||
|- | |||
| -b<br>--cookie || クッキーを指定する。 || curl -b "name=value" https://example.com | |||
|- | |||
| -c<br>--cookie-jar || 取得したクッキーをファイルに保存する。 || curl -c cookies.txt https://example.com | |||
|- | |||
| -d<br>--data || POSTリクエストで送信するデータを指定する。 || curl -d "data=value" https://example.com | |||
|- | |||
| -D<br>--dump-header || レスポンスヘッダをファイルに保存する。 || curl -D headers.txt https://example.com | |||
|- | |||
| -F<br>--form || フォームデータを送信する。 || curl -F "file=@file.txt" https://example.com | |||
|- | |||
| -H<br>--header || カスタムヘッダを追加する。 || curl -H "Content-Type: application/json" https://example.com | |||
|- | |||
| -I<br>--head || ヘッダ情報のみを表示する。 || curl -I https://example.com | |||
|- | |||
| -k<br>--insecure || SSL / TLS認証を無視する。 || curl -k https://example.com | |||
|- | |||
| -L<br>--location || リダイレクト先に追従する。 || curl -L https://example.com | |||
|- | |||
| -o<br>--output || 取得したデータをファイルに保存する。 || curl -o output.html https://example.com | |||
|- | |||
| -O<br>--remote-name || URLのファイル名でファイルを保存する。 || curl -O https://example.com/file.zip | |||
|- | |||
| -s<br>--silent || サイレントモードを有効にする。 || curl -s https://example.com | |||
|- | |||
| -u<br>--user || ユーザ名とパスワードを指定して認証を行う。 || curl -u username:password https://example.com | |||
|- | |||
| -x<br>--proxy || プロキシサーバを指定する。 || curl -x http://proxy.example.com:8080 https://example.com | |||
|- | |||
| -X<br>--request || HTTPメソッド(GET, POST, PUT, DELETE) || | |||
POSTリクエスト送信<br>curl -X POST -d “data=value” https://example.com<br><br> | |||
PUTリクエストの送信<br>curl -X PUT -d “data=new_value” https://example.com/resource/1<br><br> | |||
DELETEリクエストの送信<br>curl -X DELETE https://example.com/resource/1<br> | |||
|} | |||
</center> | |||
<br><br> | <br><br> | ||
| 101行目: | 201行目: | ||
<br><br> | <br><br> | ||
== ファイル転送 == | |||
==== FTP / SFTPでのファイルアップロード ==== | |||
# FTP | |||
curl -u <ユーザ名>:<パスワード> -T <アップロードするファイル名> ftp://〜 | |||
# SFTP | |||
curl -u <ユーザ名>:<パスワード> -T <アップロードするファイル名> sftp://〜 | |||
<br> | |||
==== FTP/SFTPでのファイルダウンロード ==== | |||
# FTPダウンロード | |||
curl -u <ユーザ名>:<パスワード> -o <保存するファイル名> ftp://〜/<ファイル名> | |||
# SFTPダウンロード | |||
curl -u <ユーザ名>:<パスワード> -o <保存するファイル名> sftp://〜/<ファイル名> | |||
<br> | |||
==== 一括ダウンロード ==== | |||
複数のファイルを一括でダウンロードする場合は、<code>-O</code>オプションを付加して、複数のURLを指定する。<br> | |||
curl -O https://〜/<ファイル名> -O https://〜/<ファイル名> | |||
<br><br> | |||
== タイムアウトの設定 == | |||
リクエストのタイムアウトを設定する場合は、<code>-m</code>オプションを付加して、秒数を指定する。<br> | |||
curl -m <秒数> <URL> | |||
<br><br> | |||
== 通信速度の最適化 == | |||
<code>curl</code>コマンドのオプションを組み合わせることにより、様々な通信状況に対応した最適化が可能である。<br> | |||
<br> | |||
例えば、低速な回線で大量のデータをダウンロードする場合は、以下に示すようなオプションを付加する。<br> | |||
* <code>-retry</code> | |||
*: 転送が失敗した場合のリトライ回数を指定する。 | |||
* <code>-retry-delay</code>オプション | |||
*: リトライする場合の待ち時間を指定する。 | |||
* <code>-connect-timeout</code> | |||
*: 接続のタイムアウト時間を指定する。 | |||
<br> | |||
curl --limit-rate <転送速度の上限> --compressed --retry <リトライ回数> --retry-delay <リトライ時の待ち時間> --connect-timeout <タイムアウト時間(秒)> <URL> | |||
# 実行例 | |||
# 転送速度を50KB/sに制限、圧縮転送を行い、最大3回のリトライ、リトライの間隔は5秒、接続のタイムアウト時間は10秒 | |||
curl --limit-rate 50K --compressed --retry 3 --retry-delay 5 --connect-timeout 10 https://example.com | |||
<br><br> | |||
== エラー関連 == | |||
==== Could not resolve host: <URL> ==== | |||
まず、PCが正常にインターネット接続されているかどうかを確認する。<br> | |||
次に、URLが正しいかどうかを確認する。<br> | |||
<br> | |||
==== Failed to connect to <URL>.com port <ポート番号>: Connection refused ==== | |||
まず、ポート番号が正しいかどうかを確認する。<br> | |||
次に、接続先のサーバが稼働しているかどうかを確認する。<br> | |||
<br> | |||
==== Operation timed out after 30000 milliseconds with 0 bytes received ==== | |||
タイムアウト時間を伸ばす、または、サーバの応答速度を改善する。<br> | |||
<br><br> | |||
{{#seo: | |||
|title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki | |||
|keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板 | |||
|description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This page is {{PAGENAME}} in our wiki about electronic circuits and SUSE Linux | |||
|image=/resources/assets/MochiuLogo_Single_Blue.png | |||
}} | |||
__FORCETOC__ | __FORCETOC__ | ||
[[カテゴリ:RHEL]][[カテゴリ:SUSE]][[カテゴリ:Raspberry_Pi]][[カテゴリ:PinePhone]] | [[カテゴリ:RHEL]][[カテゴリ:SUSE]][[カテゴリ:Raspberry_Pi]][[カテゴリ:PinePhone]] | ||