Forum: Ruby curl output from ruby script

Posted by Ferdous ara (ferdous)
on 2012-10-13 13:41
Hi
Normally when i do curl i get this
From command line

curl localhost
<html>

<body>
<p>test </p>
</body>
</html>

but when i run this from ruby script, i get this

ruby test.rb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time
Current
                                 Dload  Upload   Total   Spent    Left
Speed
100    44  100    44    0     0  25042      0 --:--:-- --:--:-- --:--:--
44000
<html>

<body>
<p>test </p>
</body>
</html>

why ruby is adding that extra line ??

how can i  ommit this

% Total    % Received % Xferd  Average Speed   Time    Time     Time
Current
                                 Dload  Upload   Total   Spent    Left
Speed
100    44  100    44    0     0  25042      0 --:--:-- --:--:-- --:--:--
44000
??

Thanks for  your help.
Posted by Brian Candler (candlerb)
on 2012-10-13 17:06
Ferdous ara wrote in post #1079699:
> why ruby is adding that extra line ??

It isn't. curl is, because you are not running curl at a terminal (or 
are redirecting the output). Try this at the terminal:

curl http://www.ruby-lang.org/ >myfile

and you'll get the same.

Want to know how to get rid of it? Type 'man curl'

...
       -s/--silent
              Silent  or  quiet  mode. Don't show progress meter or 
error mes-
              sages.  Makes Curl mute.
Posted by Robert Klemme (robert_k78)
on 2012-10-13 23:17
(Received via mailing list)
On Sat, Oct 13, 2012 at 1:41 PM, Ferdous ara <lists@ruby-forum.com> 
wrote:
> Hi
> Normally when i do curl i get this
> From command line

> why ruby is adding that extra line ??
>
> how can i  ommit this

Use Net::HTTP or Mechanize instead of an external program like curl
for HTTP.  Then you have better control about output etc.

Kind regards

robert
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.