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:
Although you can test $?, you can also test the exit status of a command directly:
if cp -rv /path/to/lab$1 /path/to/dropbox
then echo Submission successful
fi
exit $?
The errors were already reported to standard error by cp
. The exit
shown will exit with status 0 (success) if cp
was successful; otherwise, it exits with the status that cp
exited with.
Clearly, you can wrap that in a loop if you want to, or you can make it non-interactive (but any exit terminates the script).