3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FTP操作はcURLで行うと便利です

Last updated at Posted at 2019-11-29

マウス操作が多いFTPでしすが、cURLで行うと便利です。

基本

ユーザー名とパスワードを環境変数に設定しておくと使いやすいです。

$ export FTP_USER=user FTP_PASS=password

ファイルの取得(GET)

$ curl -s  --user ${FTP_USER}:${FTP_PASS} ftp://ftp.example.com/file.csv

ファイル一覧取得

ディレクトリに対してリクエストをすると一覧を取れます。

$ curl -s  --user ${FTP_USER}:${FTP_PASS} ftp://ftp.example.com/dir/

ファイル名でソートして取得

$ curl -s  --user ${FTP_USER}:${FTP_PASS} ftp://ftp.example.com/dir/ | sort | tail -n 1

アップロード

-Tもしくは--upload-file

$ curl --upload-file upload.csv  --user ${FTP_USER}:${FTP_PASS} ftp://ftp.example.com/dir/

FTP file upload using cURL | ADMFactory

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?