Alexander (HH): Dateidownload über Unix/Linux Konsole (nicht wget)

Beitrag lesen

Moin Moin!

Für's Archiv:

* curl -o datei.txt http://www.example.com/file.txt
* perl -MLWP::Simple -e 'getstore("http://www.example.com
/file.txt","datei.txt")'
* perl -MLWP::Simple -e 'mirror("http://www.example.com/file.txt","datei.txt")'
* perl -MLWP::Simple -e 'getprint("http://www.example.com/file.txt")' > datei.txt
* echo -en "GET /file.txt HTTP/1.0\r\n\r\n" | nc www.example.com 80 > datei.txt (Schleppt allerdings die HTTP-Header mit)

Mit einer halbwegs aktuellen bash geht's auch:

  
#!/bin/bash  
exec 3<> /dev/tcp/www.example.com/80  
echo -en "GET /file.txt HTTP/1.0\r\n\r\n" 1>&3  
IFS=''  
CR=$(echo -e '\r')  
while read -r -u3 LINE; do  
        [ "$LINE" = "$CR" ] && break  
        [ "$LINE" = "" ] && break  
done  
cat <&3 > datei.txt  

/dev/tcp muß NICHT existieren, das ist eine Spezialität der bash.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so".