On Wed, Jun 05, 2002 at 05:23:07PM -0400, Mike Dresser wrote:
> Here's a code fragment i'm trying to work on in bash
>
> I'm pulling a backup, and if smbtar aborts for whatever reason, I need
> to know not to rotate the backup.
>
> smbtar -s $username -x $share -p $password -t - | gzip -1 > $filename.tar.gz
> if [ $? -eq 0 ]; then
> # rotate the backup;
> fi;
> # else go on to the next machine
>
> The problem is, $? reports the result of the last command, which is gzip,
> which will ALWAYS report 0(well, unless the hd is full or the moon is
> full), because smbtar spits out data to it. If I remove the gzip -1, it
> works as expected.
man bash
search for PIPESTATUS:
PIPESTATUS
An array variable (see Arrays below) containing a list of
exit status values from the processes in the
most-recently-executed foreground pipeline
(which may contain only a single command).
> I need to gzip on the fly, because smbtar doesn't a) support compression,
> and b) 2gb filesize limits and these workstations are over 2gb in some
> cases, and c) disk space isn't free. If it wasn't for b) I'd gzip after a
> backup is done.
>
> Anyone have any ideas? My current method is to check if the backup is
> over a predefined size, but that doesn't work if the backup crashed over
> that size), so I'm trying to do it properly.
>
> Mike
>
>
> --
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>
--
Karl E. Jørgensen
karl@jorgensen.com
www.karl.jorgensen.com
==== Today's fortune:
Anyone who imagines that all fruits ripen at the same time
as the strawberries, knows nothing about grapes.
-- Philippus Paracelsus
Attachment:
pgpeFKPxaZ6Gh.pgp
Description: PGP signature