Curl command to download a file over HTTPS

5

I need to download a particular file from https://file_path. Here is the curl command I use for that:

curl --user user:password "https://file_path?raw" > location
  1. I wish to download the real contents of the file at the above "file_path" location, but somehow the curl returns the HTML content only. How would I be able to fix this?
  2. When I run this command from the shell, it runs as above to download the HTML content. But when I run it from within a bash script, it does not download anything and returns a blank file. Why would it exhibit a different behavior depending on where its being run from?

Hello

Posted 2016-05-04T15:19:31.177

Reputation: 53

How is the script itself being run? – user1686 – 2016-05-04T17:17:50.337

Looked at this? Would you define what you mean by real contents and why an HTML source doesn't fit this requirement?

– Clijsters – 2016-05-11T18:53:23.887

Answers

3

curl modifies what it sends to stdout and stderr depending if you pipe it's output, what option you use etc... You would need to post your script to see exactly why this is happening here. The best way to force the content of what you download into a specific file is to use the -o option:

curl --user user:password -o output_file "https://file_path?raw"

Depending what you do with your script, you might also want to use the -s option to suppress the download progression.

Yves Dorfsman

Posted 2016-05-04T15:19:31.177

Reputation: 175