Cross-platform, ad hoc, recursive file transfer via HTTP #
Recursively copy desired_dir located on server to current directory on client without having to fool around with usernames, passwords, config files, FTP, NetBIOS, Bonjour, etc:
On server: cd desired_dir && python -m SimpleHTTPServer
On client: wget -r -np http://server_ip_address:8000/
- SimpleHTTPServer's default listening port is 8000. Change by specifying desired port, e.g., python -m SimpleHTTPServer 8192
- Python 3 syntax: python -m http.server [<portNo>]
- A few interesting wget options:
- -r = recursive
- -np = don't ascend to the parent directory
- -nd = don't create directories (i.e., merge / flatten directories into one. WARNING: filename collisions are not handled; files with the same names will be overwritten)
- -A doc,pdf = accept only files with the extensions doc or pdf
- -R doc,pdf = reject / ignore doc and pdf files
- While both tools are preinstalled in most Linux distributions, Windows users will need to grab wget and/or Python first. OS X includes Python, but not wget; here's a binary I compiled of the latest version. Compile your own or install via Homebrew or MacPorts.
- Under Windows, the Python executable is installed to C:\Python27\ by default. Add this directory to your PATH variable if desired to make it easier to call: setx path "%path%;C:\Python27"
- A tiny, stand-alone web server like MiniWeb or HFS (HTTP File Server) will be faster and easier for Windows users who do not have Python installed already. And, though it's not tiny, OS X users may want to check out the beautiful and simple Fenix Web Server ("Finally, a simple static desktop web server. Because simple stuff shouldn't need Apache, IIS, or nginx."). Fenix review.
- Two wget alternatives for Windows:
- Ipswitch WS_FTP LE ("Transfer files over FTP, SSL, SSH, and HTTP/S transfer protocols") Copies recursively, but flattens directories without handling filename collisions.
- HttpCopy ("A command line utility that lets you copy a web file or web page to a local file") Appears to only copy individual files.
- Netcat (and the newer, more powerful Ncat) can also be used for ad hoc file transfers across the network, but it does not handle directories on its own.
- Thanks to this anonymous poster.
/nix | Jun 21, 2015
Subscribe or visit the archives