0

unable to pass values to curl command using shell variable

curl -F 'file=@/root/bin/"$VARIABLE"' http://localhost:8000/api/v1/

The error says

curl: (26) Failed to open/read local data from file/application  
mkayaalp
  • 2,631
  • 10
  • 17
kavya
  • 1
  • 1
  • 1
    the single quotes override the embedded double quotes so the variable reference (`$VARIABLE`) is not being replaced with the variable's actual value, ie, `curl` sees the literal string `"$VARIABLE"`; try replacing the single quotes with double quotes, eg: `curl -F "file=@/root/bin/$VARIABLE" http:...` – markp-fuso Apr 12 '21 at 12:34

1 Answers1

0

You can solve this problem with

curl -F "file=@/root/bin/$VARIABLE" http://localhost:8000/api/v1

Also verify that the user has the correct permission of reading for this file.

If you want to know what it is happening, use "-v" argument in curl.

sinkmanu
  • 1,034
  • 1
  • 12
  • 24