On Fri, Feb 21, 2003 at 07:50:44PM +0100, Ralf S. Engelschall wrote:
>On Fri, Feb 21, 2003, Bill Campbell wrote:
>
>> I've encountered a problem with the openpkg/shtool script when running the
>> mysql daily program, openpkg-20030203-20030203.  Around line 1816,
>> ``optionally take logfile size into account'', it's using what seems to me
>> to be a fairly comples combination of ``set, ls, and sed'' to compute the
>> file size which actually is returning the user or group name on a SuSE 8.1
>> Linux system.
>>
>> It seems to me that this would be much simpler using something like this:
>>      size=`ls -l $ldir/$file | awk '{printf "%d\n", $5}'`
>>
>> I'm attaching a diff for shtool that does this.
>
>Be careful. The reason for the current "complex" combination of set, ls
>and sed is to take the "last - 4"th argument while are taking just the
>5th argument from the front. Unfortunately the "ls -l" output contains
>+1/-1 number of columns in front of the size column. For instance, as
>far as I can remember most Unix platforms output user and group fields,
>some other strange ones just the user column. So your change might break
>other platforms. Can you provide me the output of..
>
>$ ls -l <prefix>/var/mysql/mysqld.err
>$ ls -l <prefix>/var/mysql/common.log
>$ ls -l <prefix>/var/mysql/update.log
>
>...on your SuSE platform? There seem to be some additional columns
>at the end, I think.

Here's the output for mysqld.err on my development machine.  The date part
looks different than most I've seen.

-rw-r--r--    1 csoftdev csoftdev        0 2003-02-21 09:37 /csoft/var/mysql/mysqld.err

Assuming perl's available on the machines (not necessarily valid,
but certainly it is on any we work on);

        size=`perl -e "printf (qq(%d\n), -s qq($ldir/$file));"`

Another awk'ish way to do this might be:

size=`ls -l $ldir/$file | awk '{printf ("%s\n", $5 ~ /^[0-9]$/ ? $5 : $4)}'`

>> The patch also includes ``id'' calls to fix problems that occur when
>> running on a Linux system using nss_ldap and nss_ldap where the openpkg
>> users aren't in the /etc/{passwd,group} files or found with ypcat.
>
>This part of your patch is fine and reasonable. I'll include this for
>the forthcoming GNU shtool 2.0.0.

Sounds good to me.

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``Rights'' is a fictional abstraction.  No one has ``Rights'', neither
machines nor flesh-and-blood.  Persons... have opportunities, not rights,
which they use or do not use.
    -- Lazarus Long
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
Developer Communication List                   [EMAIL PROTECTED]

Reply via email to