News for hackers. Stuff that matters.
Re:Curl Wttr.in by fortran77 on Thursday June 25, 2020 @11:34PM (#23648417)
No need for that. You can do this:

     (Invoke-WebRequest -Uri wttr.in).content
from Powershell. Why not use the happy path?
Re:Curl Wttr.in by sonofhans on Friday June 26, 2020 @12:16AM (#23648666)
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?

Re:Curl Wttr.in by majkinetor on Friday June 26, 2020 @03:45PM (#23656143)
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 by fortran77 on Friday June 26, 2020 @09:06AM (#23651522)
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.
Re:Curl Wttr.in by feteru on Friday June 26, 2020 @02:56PM (#23655596)
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 by majkinetor on Friday June 26, 2020 @03:33PM (#23656021)
> 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 by stnmtn on Friday June 26, 2020 @12:43PM (#23654015)
Do you feel like you are typing a lot more for simple things like this?
Re:Curl Wttr.in by vips7L on Saturday June 27, 2020 @11:42PM (#23666599)
Powershell comes installed with a lot of aliases.

Invoke-WebRequest is just iwr

Re:Curl Wttr.in by isoskeles on Friday June 26, 2020 @01:30AM (#23648979)
Can't speak for that person, but I'm certain it was sarcasm.
Re:Curl Wttr.in by mrunkel on Friday June 26, 2020 @12:19AM (#23648678)
Maybe it's just me, but I find PowerShell to be so verbose.

Why does every parameter have to have consist of a camelcased sentence? I'm a good typist, but I don't think what you wrote is better than

    curl wttr.in
But that might just be (my) programming.
Re:Curl Wttr.in by lzybkr on Friday June 26, 2020 @01:42AM (#23649049)
PowerShell can be shorter by 1 character for this use case:

  irm wttr.in
irm is an alias for Invoke-RestMethod which is similar to Invoke-WebRequest but better for non-html responses like json or plain text.
Re:Curl Wttr.in by bostonsre on Friday June 26, 2020 @12:54AM (#23648837)
It's case insensitive and there are short aliases for commands. I live in Linux, but used it way back when. It's an object oriented shell that is kind of awesome and intuitive. Bash is great and you can get shit done, but i don't think it's as user friendly as powershell.
Re:Curl Wttr.in by wruza on Friday June 26, 2020 @02:58AM (#23649445)
Honestly PS feels like yet another cryptic language with irregular/nih naming of functions and arguments (like AHK which is great, but invented its own megacryptic irrational language instead of taking something generic, and now you have to google every damn thing). If I programmed for PS, then okay, but seriously, Invoke-Rest-?Method, -Uri/Url, .content — how much semantics do you learn until you give up? I’d better

  http.get(url="...").body
in my console rather than this Invoke-WhatEver thing, because at least it seems programming language-y and names are consistent with all other web software.

Ed: strictly speaking, URI is not even a thing that you pass to a web request. I bet that IRM couldn’t fetch urn:isbn:0451450523.

Re:Curl Wttr.in by vips7L on Saturday June 27, 2020 @11:48PM (#23666626)
> my console rather than this Invoke-WhatEver thing, because at least it seems programming language-y and names are consistent with all other web software.

Because curl is consistent?

> urn:isbn:0451450523

Curl can't do whatever this is either?

Re:Curl Wttr.in by wruza on Sunday June 28, 2020 @06:02AM (#23667765)
Because that seems programming language-y and names are consistent with all other web software.

>Curl can't do whatever this is either?

Right. This is a valid URI, which Invoke-RestMethod uses as a parameter name (-Uri) and which is a unique id for a resource and not its location (it could be, but not in this particular case). They should not have call that argument “URI”, if what they actually do is fetching from a URL.

Re:Curl Wttr.in by sandyarmstrong on Friday June 26, 2020 @11:00AM (#23652709)
This works great from the new Windows Terminal (using PowerShell 7):

  Invoke-RestMethod http://wttr.in
For some reason they recommend that early in the readme, but not down in https://github.com/chubin/wttr.in#windows-users where they discuss various issues on Windows.

EDIT: I see now that lzybkr already suggested using the even shorter alias `irm` for `Invoke-RestMethod`. Nice!

Re:Curl Wttr.in by majkinetor on Friday June 26, 2020 @11:15AM (#23652912)
This handy function will ask and remember the city:

https://github.com/majkinetor/posh/blob/master/MM_Sugar/Get-...

Re:Curl Wttr.in by vips7L on Saturday June 27, 2020 @11:39PM (#23666592)
Even easier with Invoke-RestMethod wtte.in