David Haller wrote:
Hello,
On Mon, 12 Oct 2009, Dean Hilkewich wrote:
Anders Johansson wrote:
Hm, ok, something like this then
for clientdir in /backup/*; do cd $clientdir for daydir in $clientdir/*; do rarfile=$daydir/*.rar if [ ! -e $rarfile ]; then rarfile=$daydir/*.r01 fi
if ! test -e $rarfile; then echo "cannot find rarfile in $clientdir" >&2 continue; ### or exit? Depends what you want fi
unrar x $rarfile [ $? -eq 0 ] && rm -rf $daydir
Why the 'test'? And 'x' is the wrong command (fullpath, you want current dir, it might make no difference here though, that depends on how the rar was packed). And 'rar' is more robust, so one should prefer that over 'unrar' if rar is installed (which I assume).
rar e "$rarfile" && rm -rf "$daydir"
I'm not that sure on what conditions rar exits with a status != 0, so one might want to test / read up on that before really running that 'rm -rf'. That affects both variants.
done done
HTH, -dnh
So what would the script look like if you were to put it though David? If it exits other then 0 would it be possible to log the failure and continue on to the next leaving the failed extractions source directory untouched? This is what I found on the exit codes for rar: RAR exits with a zero code (0) in case of successful operation. The exit code of non-zero means the operation is cancelled due to error: 255 USER BREAK User stopped the process 9 CREATE ERROR Create file error 8 MEMORY ERROR Not enough memory for operation 7 USER ERROR Command line option error 6 OPEN ERROR Open file error 5 WRITE ERROR Write to disk error 4 LOCKED ARCHIVE Attempt to modify an archive previously locked by the 'k' command 3 CRC ERROR A CRC error occurred when unpacking 2 FATAL ERROR A fatal error occurred 1 WARNING Non fatal error(s) occurred 0 SUCCESS Successful operation (User exit) Thanks for your guys help once again Dean -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org