I am very new to bash scripts, and for my first script attempt I am submitting files to my professor\'s dropbox within the same server.
The code is this:
To check the return code from the previous command, you can use the $? special variable as follows:
if [ "$?" -ne "0" ]; then
echo "Submission failed"
exit 1
fi
echo "Submission successful."
Additionally, if you want a clean prompt, you can redired stderr
as explained here.
Finally, you can also use this in the script that uses scp
, since it works regardless of the command you're using.