Curl command to download a file over HTTPS

18,112

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.

Share:
18,112

Related videos on Youtube

Hello
Author by

Hello

Updated on September 18, 2022

Comments

  • Hello
    Hello over 1 year

    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?
    • user1686
      user1686 about 8 years
      How is the script itself being run?
    • Clijsters
      Clijsters almost 8 years
      Looked at this? Would you define what you mean by real contents and why an HTML source doesn't fit this requirement?