clt60
clt60

Reputation: 63902

bash version of curl - waiting forever

Why not working this bash version of curl? (waiting forever)

url="$1"
uri=($(echo "$url" | sed 's~http://\([^/][^/]*\)\(.*\)~\1 \2~'))
HOST=${uri[0]:=localhost}
FILE=${uri[1]:=/}
exec {SOCKET}<>/dev/tcp/$HOST/80
echo -ne "GET $FILE HTTP/1.1\nHost: $HOST\n" >&${SOCKET}
<&${SOCKET} sed -e '1,/^.$/d'

Upvotes: 1

Views: 365

Answers (1)

clt60
clt60

Reputation: 63902

Already found the problem:

echo -ne "GET $FILE HTTP/1.1\nHost: $HOST\n\n" >&${SOCKET}
                                            ^
                                            | missing one \n

So if someone want use bash for the web get - don't forget: here must be an empty line at the end.

Upvotes: 1

Related Questions