0

eg. I can execute below command in terminal successfully:

curl -sX POST -F 'file=@/tmp/test.tgz' -F 'fileName=test.tgz' http://localhost:8080/upload

However, if I replace the file path str "/tmp/test.tgz" with a variable in a bash shell script, then it wouldn't work, could you please help to tell me how to resolve it?

curl -sX POST -F 'file=@$myfile' -F 'fileName=test.tgz' http://localhost:8080/upload

2 Answers 2

1

Use " instead of ' if you want variable expansion

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

Comments

0
ff="'file=$myfile'"
fname="'fileName=test.tgz'"
eval curl -sX POST -F $ff $fname http://localhost:8080/upload

Comments

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.