2

I'm trying (learning) to use curl to download the file http://cscope.sourceforge.net/cscope_maps.vim . The commands I have tried are:

curl -o cscope_maps.vim cscope.sourceforce.net/cscope_maps.vim
curl -O cscope.sourceforce.net/cscope_maps.vim
curl -LO cscope.sourceforce.net/cscope_maps.vim
curl -L cscope.sourceforce.net/cscope_maps.vim > cscope_maps.vim

All of the above commands result in me getting a file with the following content:

<html><head><script type="text/javascript">location.replace("https://malware.opendns.com/?url=cscope.sourceforce.net%2Fcscope_maps.vim&server=lax20&prefs=&tagging=&nref");</script></head></html>

...instead of the actual file. What am I doing wrong, and what is the correct syntax to download a file with curl?

(If I enter the noted URL in a graphical browser, I see expected file contents, so I'm sure the URL is correct)

PS: I'd like to learn how to solve this with curl and not wget.

What else I have tried:

I read https://stackoverflow.com/questions/27458797/curl-command-doesnt-download-the-file-linux-mint which prompted me to try the -L options, but as noted above, this did not change the observed behavior.

closed as off-topic by Michael Homer, dhag, cuonglm, Satō Katsura, Archemar Mar 22 '17 at 8:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Michael Homer, dhag, cuonglm, Satō Katsura, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Your first command (using -o for output) actually works. I tried it on my side. I think the problem might be on the DNS. If you look at your output, instead of getting the contents of cscope_maps.vim, you're getting warning from opendns that you are downloading malware. Check your antivirus or firewall, perhaps? – Sutandiono Mar 22 '17 at 1:02
  • 2
    Your examples have "sourceforce.net" URLs, but what you want is at cscope.sourceforge.net/cscope_maps.vim, right? (“forge” instead of “force”) … – sideshowbarker Mar 22 '17 at 1:04
  • @sideshowbarker and Fox: good catch. I also didn't notice the typo on the URL. FYI, the output file that was given by the curl running on my machine is listing the domain for sale. – Sutandiono Mar 22 '17 at 1:18
4

Your opening statement indicates you are trying to download from sourceforge.net

" I'm trying (learning) to use curl to download the file http://cscope.sourceforge.net/cscope_maps.vim ..."

However, your attempts are using sourceforce.net

This curl man page describes what you are trying to do:

curl [options] [URL...]

with the -o option being what you're looking for

-o/--output

Write output to instead of stdout. If you are using {} or [] to fetch multiple documents, you can use '#' followed by a number in the specifier. That variable will be replaced with the current string for the URL being fetched. Like in:

curl http://{one,two}.site.com -o "file_#1.txt"

or use several variables like:

curl http://{site,host}.host[1-5].com -o "#1_#2"

You may use this option as many times as you have number of URLs.

Your first attempt should work once you correctly spell sourceforge

curl -o cscope_maps.vim cscope.sourceforge.net/cscope_maps.vim  

This worked for me.

  • I should crawl and hide under a rock for the rest of my life out of abject embarrassment. I can't believe I posted a question in public over a typo. Thank you: you were correct, my attempts worked once I spelled the URL correctly. – StoneThrow Mar 22 '17 at 19:15

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