Thankyou all for your suggestions. I now have it working perfectly! :) It is a very unusual way of doing things I know. It's a really complicated backup program. Sorta hard to explain, but the clients wanted it and they like it, so it works well.
I needed the return value from tar so I could say whether or not any errors were reported, so that the clients could be sure the backup was completed properly. Just in case anyone is wondering, I ended up doing it this way: echo the number out to a temp file ( $retf ), and then I read it in later. ( tar -cvpzf $dev $dir 2>>$backup_error_report; echo $? >$retf 2>/dev/null ) | while read line ... Tried setting it as a variable, but because it's in the subshell, the variable doesn't exist once it's finished. So that way is fine by me, thanks again! ________________________________________________________________ Kevin Green KD Micro Software MP 107, Market City 280 Bannister Road CANNING VALE WA 6155 Phone: 08 9256 1566 Ext: 2778 Mobile: 0439 696 585 E-Mail: [EMAIL PROTECTED] Internet: http://www.kdmicro.com.au ----- Original Message ----- From: "Jan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, January 21, 2003 9:26 PM Subject: Re: Shell Script Returned Value > Kevin - KD Micro Software wrote: > > Hello everyone, > > > > I have a small programming question here, which I'm not sure if it's > > possible to do or not, but any suggestions would be greatly appreciated. > > What I need is for the following to return with the appropriate exit status > > value ( $? ). > > > > ---- Start Code ---- > > tar -cvzf $dev $dir 2>>$backup_error_report | while read line > > do > > ...(conditions here)... > > done > > retval="$?" > > ---- End Code ---- > > > > Because I'm piping the 'tar' output to 'read', no exit status value is > > returned. Is there any way I could still get tar's return value doing it > > this way?.... If that makes any sense to anyone. > > > The problem is that tar runs in a subshell, so the return code is lost. > You'll have to either not use a pipeline (output to a temp file), or > else something like: > > (tar -cvzf $dev $dir 2>>$backup_error_report; print $? )| while read line > > - and then interpret the last value of line. > > /jan > > > > -- > redhat-list mailing list > unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe > https://listman.redhat.com/mailman/listinfo/redhat-list > -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list