I have written several Bash scripts that use curl requests to upload multipart files to the server. If I call those scripts one by one, they all work as expected.
However, if I call them from the "root" script, that invokes them one by one, then my curl requests fail. This is the error I'm getting.
curl: (26) Failed to open/read local data from file/application
The script that uses curl to upload multipart file (normally works).
#!/bin/bash
curl --location --request POST 'localhost:8080/rest/v2/photos' \
--header 'Content-Type: multipart/form-data' \
--header "Authorization: Bearer $user_login_token" \
--form 'image=@./photos-webp/photo-profile-2.webp' \
--form 'metadata=@./photos-webp/photo-profile-2-metadata.json;type=application/json'
The "root" script that invokes the curl script (yields the error).
#!/bin/bash
find . -print0 | while IFS= read -r -d '' file
do
if [[ $file == *.sh ]]; then
. $file
fi
done
I don't understand why it normally works, but doesn't work when invoked from another script. How do I fix that?
if [[ ...test by tellingfindto return only.shfiles, usingfind . -name '*.sh' -print0 .... Good luck.