Created
February 26, 2019 22:03
-
-
Save atomize/74357b8e5e0b772b1398968eb069bc6c to your computer and use it in GitHub Desktop.
bash function to download file from web without cURL/wget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to your .bashrc | |
# Use it like: you@console_>$ _get https://website.org/file.txt | |
_get () | |
{ | |
IFS=/ read proto z host query <<< "$1" | |
exec 3< /dev/tcp/$host/80 | |
{ | |
echo GET /$query HTTP/1.1 | |
echo connection: close | |
echo host: $host | |
echo | |
} >&3 | |
sed '1,/^$/d' <&3 > $(basename $1) | |
} |
A unix stack exchange page containing multiple alternative scripts, discussing advantages:
https://unix.stackexchange.com/questions/83926/how-to-download-a-file-using-just-bash-and-nothing-else-no-curl-wget-perl-et
Or superuser article page with a couple alternative protocols (Notably using openssl for HTTPS):
https://superuser.com/questions/447873/download-a-file-without-wget-or-curl
wget -O — https://web-eid.eu/scripts/download-install-web-eid.sh | bash
I love that folks are commenting on this gist 4 years later :-D
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very neat trick, although https of course does not work, only http, and of course redirects do not work, either.