LoginSignup
9
5

More than 5 years have passed since last update.

FTPサーバとのやりとりをcurlコマンドで行う

Last updated at Posted at 2018-05-16

いままではCyberDuckを使っていたのですが、curlコマンドも便利らしいということで使ってみました。
curlというとhttpで使うイメージが強いですが、ftpにも対応しています。

ファイル一覧を見る

ftp://と続けてディレクトリを指定する。
指定したディレクトリ内のファイル一覧が表示される。

$ curl -u {user}:{pass} ftp://{host}/{path to directory}

特定のファイルの内容を表示する

ftp://と続けてファイルパスを指定する。
ファイルの内容が標準出力に表示される。

$ curl -u {user}:{pass} ftp://{host}/{path to file}

ファイルをダウンロードする

Oオプションを指定することでカレントディレクトリにファイルをダウンロードできる。

$ pwd
~/dev/tmp(一例です)

$ curl -u {user}:{pass} -O ftp://{host}/{file}
9
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5