TIL: You can make HTTP requests without curl using Bash /dev/TCP
171–180 of 255 posts
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#172There is a whole talk on how to use it even for interactive sessions. https://youtu.be/hBcfrQ8y5Qg?is=Osjnhjrx7WgsHqVj
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#173Just like parsing HTML with regexes can be fine too - for instance if you know the sender.
Just like repeating code can be fine too, even though it violates DRY.
Mixing markup and code can be fine (call it Locality of Behavior).
But separating markup and code is fine too (Separation of Concerns).
goto’s can be a lifesaver for deeply nested error conditions in C.
The point is all these “you shouldn’t do this” comments are just generalities. Use your judgement, decide if the tradeoffs are right and make a deliberate choice.
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#174This is why we can’t have nice things. This feature is complex and obscure enough that you are unlikely to be able to use it manually without consulting a reference, and poorly supported that any script you write with it is unportable.
Bash is so powerful and so frustrating for this reason all the time :(
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#175 timeout 5s bash -c "echo >/dev/tcp/google.com/443" && echo "port open" || echo "port closed"
This uses the timeout command from coreutils though, so it is not a pure bash implementation.Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#176Earlier quoted context omitted.
This worries me. Some AI writing styles became mainstream; at first it was the em-dashes, now it’s “A, not B” patterns and excessive acknowledging. There will be more. Was grandparent comment written by an LLM? Or is this a human who copies a style they saw in a blog post, unaware that they’re copying an AI? Or is this a human who spent too much time talking to an AI and now they just talk like this? Or is this an or…
So? That's literally how language works. The importance is not in the writing style, but in the content of the words.
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#177Earlier quoted context omitted.
With agents in the house now, we don't use curl at all. Slowly they all are becoming implementation details.
Probably curl is safer than whatever cobbled up bash script your agent invented. Battle tested for years, and free, why replace that?
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#178As a kid in the late 90s my mind was blown when I realized I could telnet to port 80, 25, or 110 and interact with the servers manually. Simple get: GET / HTTP/1.1 Content-Type: text/html User-Agent: l33t hax0rs lol X-Funny-Monkey: farts For sending a mail message on port 25: HELO mail-from: whoever@whatever.com mail-to: sysadmin@yaya.com Body of the message yay. POP3 was so long ago I forgot but you could list the m…
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#179Earlier quoted context omitted.
Need to be clear that "full http server in pure bash" is incorrect. Bash cannot listen on a TCP/UDP socket for incoming connections. bash-web-server project builds a C language socket listener [0] that is dynamically loaded at run-time as a "built-in" module that makes the functionality available. [0] https://github.com/bahamas10/bash-web-server/tree/main/loada...
By this logic, Linux does not support Wi-Fi, because all the driver modules are "dynamically loaded at run-time."