felixhageloh / uebersicht-widgets

A collection of community widgets for Übersicht
360 stars 106 forks source link

Curl -I doesn't return the same thing as the terminal #62

Closed joshuaswilcox closed 10 years ago

joshuaswilcox commented 10 years ago

I am trying to write a widget to check website status, but its not returning the same results as terminal

command:  'curl -I http://google.com'

returns

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

but in the console

curl -I http://google.com

returns

HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Thu, 07 Aug 2014 22:35:45 GMT
Expires: Sat, 06 Sep 2014 22:35:45 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alternate-Protocol: 80:quic

I want to be able to do

output.split('\n')[0]

to get the http status. Any ideas?

joshuaswilcox commented 10 years ago

Also would it be possible to run brew commands? I would like to use https://github.com/jakubroztocil/httpie for checking http status but it requires brew

felixhageloh commented 10 years ago

What's happening most likely is that what you see in the console is logged to stderr but Übersicht only sends stdout to the widget. You could try piping stderr to stdout or check if there is an option to have curl not log this to stderr

felixhageloh commented 10 years ago

regarding homebrew: I guess you have two options. You could either instruct people to install httpie in the readme or you could just ship the compiled binary along with your widget (in the widget folder).

joshuaswilcox commented 10 years ago

Ok that makes sense. I ended up calling "source $HOME/.bash_profile && ...." to get to my normal environment and call what I needed