Skip to content

Instantly share code, notes, and snippets.

@LivingGhost
Last active September 21, 2020 02:35
Show Gist options
  • Save LivingGhost/c422da40d0a7c2a86e64a7b9d3a97ef7 to your computer and use it in GitHub Desktop.
Save LivingGhost/c422da40d0a7c2a86e64a7b9d3a97ef7 to your computer and use it in GitHub Desktop.
全世界のIPv4割り当てリストを取得するbat
@echo off
REM 共通変数
set download_dir=%~dp0%download
REM ログインユーザ
set login_user=anonymous
set login_password=
REM メイン処理
set target_host=ftp.apnic.net
set target_path=/pub/apnic/stats/apnic
set target_file=delegated-apnic-latest
set pasv_mode=FALSE
call :download
set target_host=ftp.arin.net
set target_path=/pub/stats/arin
set target_file=delegated-arin-extended-latest
call :download
set target_host=ftp.ripe.net
set target_path=/pub/stats/ripencc
set target_file=delegated-ripencc-extended-latest
call :download
set target_host=ftp.lacnic.net
set target_path=/pub/stats/lacnic
set target_file=delegated-lacnic-extended-latest
set pasv_mode=FALSE
call :download
set target_host=ftp.afrinic.net
set target_path=/pub/stats/afrinic
set target_file=delegated-afrinic-extended-latest
call :download
REM 終了
pause
exit /b
REM ダウンロード実行
:download
call :output-datetime
echo [%target_host%]: %target_path%/%target_file%
if not "%pasv_mode%"=="FALSE" (set pasv_mode=--ftp-pasv) else (set pasv_mode=)
curl -u %login_user%:%login_password% %pasv_mode% ftp://%target_host%%target_path%/%target_file% --output %download_dir%\%target_file% --create-dirs --progress-bar
echo.
exit /b
REM 現在日時を画面出力
:output-datetime
call :datetime
echo [%yyyy%/%MM%/%dd%-%HH%:%mt%:%ss%.%sss%]
exit /b
REM 現在日時の取得
:datetime
set date2=%date:/=%
set time2=%time: =0%
set yyyy=%date2:~0,4%
set MM=%date2:~4,2%
set dd=%date2:~6,2%
set HH=%time2:~0,2%
set mt=%time2:~3,2%
set ss=%time2:~6,2%
set sss=%time2:~9,2%
set date2=
set time2=
exit /b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment