News for hackers. Stuff that matters.
Re:Why use www? by buzzdenver on Sunday January 31, 2016 @10:32AM (#11006669)
Can I ask you to explain that "-o\ /dev/null{,\ }" magic ?
Re:Why use www? by drostie on Sunday January 31, 2016 @11:12AM (#11006783)
It's not magic -- it's some form of crude error.

So first off what this does is, it expands to the expression:

    '-o /dev/null' '-o /dev/null '
Even if we remove the latter space by just using `{,}` instead of `{,\ }` curl still returns for me an error code 23 -- CURLE_WRITE_ERROR.

curl seems to interpret `'-o /wtf'` as a command to write to the file ` /wtf`, so this only makes sense if you have a directory called ` ` in the folder you're running from.

You can therefore do this correctly with:

    -o/dev/null{,}
and that correctly writes the contents to /dev/null without issuing a curl write error.
Re:Why use www? by wangman on Sunday January 31, 2016 @12:45PM (#11007129)
Thanks, it sure looks less ugly with -o/dev/null{,} I couldn't find any other way to get curl to stay silent and still output redirect times. Hence the crude hack. (Obviously my bash and curl versions had no problem with the spaces or I wouldn't have posted it)
Re:Why use www? by d0ugie on Sunday January 31, 2016 @04:34PM (#11008186)
Using the curl'ing tips up this branch of comments I programmed a highly sophisticated script and dropped it on github. :)

https://github.com/dougsimmons/301debate

Re:Why use www? by wangman on Sunday January 31, 2016 @05:41PM (#11008504)
Nice!

I would have gone for a simpler loop:

echo -e "sec\tmethod\turl";for url in {https,http}://{www.,}{en.wikipedia.org,{google,reddit,facebook,youtube,netflix,amazon,twitter,linkedin,msn}.com,google.co.in}; do curl -sL "$url" -w "%{time_redirect}\t${url%:}\t${url#//}\n" -o/dev/null; done|sort

Re:Why use www? by d0ugie on Sunday January 31, 2016 @06:31PM (#11008681)
Wow. Thanks for teaching me that. Yeah, yours is better, I'll lay it on github with a thank you and maybe "embrace and extend" it.

Or learn python and port it to python, I could swing it that way.. Cheers.