Oh boy, this was actually a tricky one.
It seemed easiest to use the auto-kill option for zenity instead of auto-close. But, to allow for this, I used two scripts.
The first is the main controller script,
foo.sh:
Code:
#!/bin/bash
./bar.sh
if [ "$?" != 0 ]; then
zenity --warning --title "CANCELED" --text "Aborted by user, FILES NOT DELETED."
exit
fi
The second actually does the work. Of course, it needs to be cleaned up, but you can probably take it from here. I just touched a file if the sums matched to avoid some of the complications of communicating with subshells, zenity, etc. This is
bar.sh:
Code:
#!/bin/bash
path=/some/path
filename=cool_file.txt
dirsum=foobar
rightsum=41eb1e3a6420cec82a32c2ad2a8711e7
nothing=baz
matchfile=/home/thobbs/.matchfile
if [ -e "$matchfile" ]; then
rm "$matchfile"
fi
while true; do
(
echo $'\n'
dirsum=`md5sum $path/$filename`
dirsum=${dirsum:0:32}
if [ "$dirsum" == "$rightsum" ]; then
touch "$matchfile"
fi
) | zenity --progress --pulsate --title="MD5" --text="Checking MD5 checksum of copied file..." --auto-kill
if [ ! -e "$matchfile" ]; then
if zenity --question --title="WARNING" --text="WARNING: File corrupted during copy. Try again?"; then
$nothing
else
exit 0
fi
else
zenity --info --title="MD5" --text="Sums matched."
rm "$matchfile"
exit 0 # the sums matched
fi
done
I hope that helps! It was an interesting problem.
-
thobbs