/* steve jansen */

// another day in paradise hacking code and more

A Better FTP Client for Windows You Already Have: Git Bash's Curl Command

| Comments

My shop has a couple of internal FTP servers to mirror commonly used installers for .Net devs. Installers for apps like Visual Studio can be huge, so GitHub isn’t the best place for this, and it would also smoke most of our Dropbox quotas. So an FTP server seems like the 3rd best option.

We are a geographically distributed team, with a VPN to access internal servers. Even with a reliable VPN session over ISP fiber connection, I’ve experience lots of realiability problems downloading large files with the native Windows Explorer / Internet Explorer FTP.

The Windows ftp command line client can be a pain to work with. Fortunately, the Git bash emulator for Windows (msysgit) includes a MinGW port of the awesome curl utility. The curl utility has all kinds of awesome features for downloading large files.

Here’s a few options I found really useful:

1
curl -C - -v -O "ftp://ftp.example.com/path/to/file.zip"
  • -C - option tells bash to automatically continue an interrupted download, if the server supports this feature.
  • -v prints verbose stats, including an dynamic progress info
  • -O automatically saves the file using the remote file name to the current working directory

I crafted this gist to enable downloading a large number of binaries related to .Net development from our FTP server.

SETLOCAL
PUSHD "%USERPROFILE%\Downloads"
IF NOT EXIST "installers" MKDIR "installers"
CD "installers"
ECHO @ECHO OFF > curl.cmd
ECHO TITLE "%~1" >> curl.cmd
ECHO IF NOT ".%~p1"==".\" IF NOT EXIST ".%~p1" MKDIR ".%~p1" >> curl.cmd
ECHO PUSHD ".%~p1" >> curl.cmd
ECHO "%ProgramFiles%\Git\bin\curl.exe" -C - -v -O "ftp://ftp.example.com/path/to/installers%~1" ^&^& PAUSE >> curl.cmd
START "" "%COMSPEC%" /D /C "curl.cmd ^"/dotNetFx40_Full_x86_x64.exe^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Internet Information Services 7.5 Express/iisexpress_1_11_x86_en-US.msi^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Internet Information Services 7.5 Express/rewrite_2.0_rtw_x86.msi^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Microsoft SQL Server 2008 Express R2 SP1/SQLEXPRWT_x86_ENU.exe^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Microsoft Visual Studio 2010/VS2010PREM_ENU.zip^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Microsoft Visual Studio 2010 SP1/VS10sp1-KB983509.exe^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Microsoft SQL Server Data Tools/SSDT_10.3.31009.2_EN.iso.zip^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Microsoft SQL Server 2012 Tools/SQLManagementStudio_x86_ENU.exe^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Microsoft SQL Server 2012 Tools/x86/SqlLocaLDB.MSI^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/Microsoft Web Deploy V3/WebDeploy_x86_en-US.msi^""
START "" "%COMSPEC%" /D /C "curl.cmd ^"/MSBuild Extension Pack 4.0/MSBuild Extension Pack 4.0.msi^""
DEL /Q curl.cmd
POPD
ENDLOCAL

Be warned, this hack spawns a new command prompt window for each download, so it can get a bit crazy. This seemed like the best worst way to download in parallel while also making sense of each download’s status.

Comments

Please enable JavaScript to view the comments powered by Disqus.

AltStyle によって変換されたページ (->オリジナル) /