0

I have a bash script that loops through all files in a directory and makes a curl request to some URL

for FILE in ./files/*;
    do  
        echo "Making a request..."
        echo $FILE

        curl --location --request POST "${URL}" \
        --form 'file=@"${FILE}"' \

        sleep 100
    done

echo "done!"

The curl request was copied from postman so I'm confident that it works.

When I run the script, I get the following

Making a request...
./files/split1.csv
curl: (26) Failed to open/read local data from file/application

The issue I'm getting is how to handle string interpolation here.

1 Answer 1

1

You are very close, just remove the single quotes to get the string interpolation to work.

curl --location --request POST "${URL}" \
--form file=@"${FILE}" \
Sign up to request clarification or add additional context in comments.

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.