I'm writing a bash script where I want to upload a file using curl. I want to print in a log file the output from stdout and stderr (to see if the upload is being completed). This is what works so far:
curl -T home/user/mydir/filename <my url>/.../filename >> home/user/mydir/script.log 2>&1
Now, I also want to get the returned http code so I can use it somewhere else in my script. The following works as well:
CODE=$(curl -w '%{http_code}' -T home/user/mydir/filename <my url>/.../filename)
How can I combine these two commands? I want to print the stdout and stderr in the log file (append, to be precise) and also store the returned http code in a variable for later use.
Thank you.