News for hackers. Stuff that matters.
Re:The Beauty of Unix Pipelines by philsnow on Friday June 05, 2020 @04:00AM (#23426116)
elsewhere in this thread somebody mentions socat, but you can do it entirely within bash. from https://www.linuxjournal.com/content/more-using-bashs-built-... :

    exec 3<>/dev/tcp/www.google.com/80
    echo -e "GET / HTTP/1.1\r\nhost: http://www.google.com\r\nConnection: close\r\n\r\n" >&3
    cat <&3
https://news.ycombinator.com/item?id=23422423 has a good point that "everything is a file" is maybe less useful than "everything is a file descriptor". the shell is a tool for setting up pipelines of processes and linking their file descriptors together.
Re:The Beauty of Unix Pipelines by JdeBP on Friday June 05, 2020 @04:48AM (#23426379)
Daniel J. Bernstein's little known http@ tool is just a shell script wrapped around tcpclient, and is fairly similar, except that it does not use the Bashisms of course:

    printf 'GET /%s HTTP/1.0\nHost: %s:%s\n\n' "${2-}" "${1-0}" "${3-80}" |
    /usr/local/bin/tcpclient -RHl0 -- "${1-0}" "${3-80}" sh -c '
    /usr/local/bin/addcr >&7
    exec /usr/local/bin/delcr <&6
    ' |
    awk '/^$/ { body=1; next } { if (body) print }'