Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know both wget and curl. Being curious I read a little about their differences.

I recently tried to use curl with an url who has parameters and it turns out curl strips down the parameters from the url. The consequence is : I don't get the page I requested.

So my question was, why does the curl command do that ?

Edit :

I tried following

# bare
$ curl -s http://tag.mobitrans.fr/horaires/index.asp?rub_code=23&lign_id=4&sens=2

# double quotes
$ curl -s "http://tag.mobitrans.fr/horaires/index.asp?rub_code=23&lign_id=4&sens=2"

# single quotes
$ curl -s 'http://tag.mobitrans.fr/horaires/index.asp?rub_code=23&lign_id=4&sens=2'

# escaping special chars
$ curl -s http://tag.mobitrans.fr/horaires/index.asp?rub_code=23\&lign_id=4\&sens=2

FWIW : curl 7.34.0 (x86_64-apple-darwin13.0.0) libcurl/7.34.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.26

share|improve this question
    
The "bare" case is irrelevant; the shell is interpreting the & character and not passing it on to curl. The others are problematic, but can be reduced to the case with single quotes. I suggest removing all but the single-quote case from your question to avoid confusion. –  Keith Thompson Feb 19 at 23:08

1 Answer 1

up vote 2 down vote accepted

Please post the command you used? It's likely you just needed to escape the URL because it had special characters to the shell such as apersands (&).

Example

$ curl http://tools.pingdom.com/fpt/#!/dnmIG9/www.google.com
bash: !/dnmIG9/www.google.com: event not found

However if I put the URL in single quotes:

$ curl 'http://tools.pingdom.com/fpt/#!/dnmIG9/www.google.com' |& head -10
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">-->
<!DOCTYPE html>
<head itemscope itemtype="http://schema.org">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="description" content="Use this free Website Speed Test to analyze the load speed of your websites, and learn how to make them faster.">
    <!-- Google PlusOne -->

Other issues

Sometimes you need to have cookies local or you need to be a certain type of browser or even have to appear to be coming from a particular URL within the site. In those instances you can often times finagle your way around them using additional switches to curl. The same can be done with wget too, by the way.

share|improve this answer
    
Please see my edit. –  Matthieu Riegler Feb 19 at 22:57
    
@MatthieuRiegler - yes that looks to be the exact issue I'm describing. Put the URLs in single quotes 'URL'. –  slm Feb 19 at 23:01
    
See my 3rd try. I'm not getting what I expected. –  Matthieu Riegler Feb 19 at 23:04
    
@MatthieuRiegler - Can you give us the error message that you're getting with the single quotes? –  slm Feb 19 at 23:07
    
Hummm you seems to be right, it's seems to be a cookies issue. Without the quotes I get 3 process, with them I only get one. –  Matthieu Riegler Feb 19 at 23:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.