Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Fw: poor man's wget



I found it on c.u.s

Amusing is it :-)

-andrej

"brian hiles" <bsh@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:<sj2npdk15pj111@xxxxxxxxxxxxxxxxxx>...
> Martin Ramsch <m.ramsch@xxxxxxxxxxxx> wrote:
> > I only now discovered the special handling of redirections to
> > /dev/tcp/host/port introduced with Bash 2.x, and I like this small
> > contruct which requests the main page from a web server:
> >   { echo "GET /" >&0; cat; } <>/dev/tcp/www.server.com/80
> > Also the first time a "<>" redirection is useful for me ... ;-)
>
> The /dev/{tcp,udp} special notation is a reflection of the same
> feature introduced in ksh93 (at least I think I'm getting the
> relationship correct!) BTW, "<>" is an undocumented feature of
> plain ol'd bourne shell since, well, _forever_.
>
> Jeffery Korn (yes, son of _that_ guy) posted a similar solution two
> years of so back to this newsgroup.
>
> Apparently, however, bash 2.x does ksh93 one better by not requiring
> the <hostname> address to be resolved to an IP address. Kudoes to
> the bash development team :)
>
> Incidentally, I would rephrase the above as:
>
> { echo GET /; echo; cat; } <>/dev/tcp/www.server.com/80
>
> Isn't the additional newline necessary? (Not tested.)
>
> It's quite amusing to determine the time from a daytime server:
>
> read -r </dev/udp/0.0.0.0/13; print -r -- "$REPLY"
>
> -Brian



Messages sorted by: Reverse Date, Date, Thread, Author