Check command success in bash
I'd do:
ok=true
if dd ...; then
sync
else
ok=false
fi
cp ... || ok=false
if "$ok"; then
mformat...
fi
Since you are using bash just add:
set -e
to the beginning of your script and it will fail whenever any of the commands failed.
Try with:
dd <command>
DD_EXIT_STATUS=$?
cp <command>
CP_EXIT_STATUS=$?
if [[ DD_EXIT_STATUS -eq 0 && CP_EXIT_STATUS -eq 0 ]]; then
format floppy disk
else
... other stuff ...
fi