I have a script in Ubuntu that copy only one file each hour to the Storage Account. I am using azcopy filename.tar https://<storage>.blob.core.windows.net/<container>
.
This script is working but I'd like to check if the copy was success or not, for example:
validcopy = azcopy copy filename.tar https://<storage>.blob.core.windows.net/<container>
if(validcopy){
echo "Success"
} else {
echo "Failure"
}
Also, I tried using Power Shell in linux (pwsh), but unsuccess.
Please, can someone help me?
I got a alternative solution for this issue. I used exit code in bash shell. Every Linux or Unix command executed by the shell script or user has an exit status. Exit status is an integer number. 0 exit status means the command was successful without any errors. A non-zero (1-255 values) exit status means command was a failure.
A particular shell variable called $?
to get the exit status of the previously executed command
It was like this:
azcopy copy filename.tar https://<storage>.blob.core.windows.net/<container>
if [[ $? -gt 0 ]]
then
echo "Failure"
else
echo "Success"
fi