0

I am trying to execute curl commands from my shell script on OSx el Capitan. How can i pass a variable to the curl script. I tried this: var ="some variable" curl -O '$var' But its not working. Thanks in advance

2
  • Do you also have space between var and ="some variable" in your script? And what does "its not working" mean? Commented May 30, 2016 at 17:53
  • Yes its a long string of data and the variable changes everytime to give me a 200 OK , but it doesn't . Commented May 30, 2016 at 17:56

1 Answer 1

1

Single quotes may be preventing interpolation of the variable. Try this as a sample:

export var="http://www.google.com/"
curl "$var"
Sign up to request clarification or add additional context in comments.

3 Comments

My bad am using a bunch of data not just the url so its curl -O --data 'random data=$var& some other data'
It's the same problem, regardless. Your variable won't be interpolated inside single quotes; you need double ones to get anything except what you literally typed.
Thanks a ton will try this

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.