Live data from Hacker News

TIL: You can make HTTP requests without curl using Bash /dev/TCP

mareksuppa.com

171–180 of 255 posts

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#173
For a light-weight aliveness check or something like that this is perfectly fine approach.

Just 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

#174
> This is a bash feature, not POSIX. dash (Debian’s /bin/sh) and zsh don’t have it, so a #!/bin/sh script can’t use it. Call bash directly.

This 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

#176
post #31

Earlier 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.

Those are not separate things.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#177

Earlier 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?

Why? Your agents knows rhyme but no reason.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#178

As 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…

I never figured out you could do it with HTTP, but for some reason I did for FTP and IRC. I don't know why I first tried using a telnet client but I couldn't believe it when the server responded to me!

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#179
post #76

Earlier 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."

Correct. It doesn't.
Post reply on HN