0

I need to download remote files using curl command below

curl -O -J "URL"

This is working as expected when I use this command separately when I try to use the same command in a shell script(below). it gives error below.

#!/bin/bash 
$curl -O -J "$url_final"
=======================================================
"curl: (3) URL using bad/illegal format or missing URL"
3
  • What's your $url_final, and is $curl a typo ? Commented Feb 17, 2018 at 6:14
  • url_final is a variable which will download files. Curl is not a typo, it is working as a separate command in the terminal. Commented Feb 17, 2018 at 6:34
  • where $url_final is defined inside the script ? I am talking about the $ sign in front of curl inside the script, is that a typo ? Commented Feb 17, 2018 at 6:36

1 Answer 1

1

Using a valid url in my tests seemed to have no issues with this curl request. I also tried using with and without wrapping the url in a string like you are along with using brackets.

url="https://cdn.sstatic.net/Sites/stackoverflow/img/sprites.svg?v=1b3cdae197be"

# all work fine
curl -O -J $url 
curl -O -J "$url"
curl -O -J "{$url}"

My best answer is that your $url_final variable is undefined, empty, or malformed.

Sign up to request clarification or add additional context in comments.

1 Comment

I feel the problem is the URL which I am generating. I have to revisit the URL again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.