Subject: Re: release script problem

From: "Dmitry Yu. Bolkhovityanov" <[email-masked]>
Date: Mon, 9 Apr 2001 12:54:00 +0700

On  8 Apr 01 at 10:47, [email-masked] wrote:

> > >   echo `date +%Y-%m-%d`"  $FVWMRELNAME  <$FVWMRELEMAIL>" > $NCLOG
> > >   echo >> $NCLOG
> > >   echo "    * NEWS, configure.in:" >> $NCLOG
> > >   echo "    changed version to $VRELNUMP" >> $NCLOG
> > >   echo >> $NCLOG
> > >
> > > FVWMRELNAME is for the release being created, 2.3.31, and
> > > VRELNUMP is the next release.
> >
> > Ah, no.  FVWMRELNAME is the name of the person who built the
> > release.  It shows up in the ChangeLog entry.  The name is not
> > very good, though :)
>
> Darn, I had a feeling I was doing something wrong there.
> I looked around for anything I might have to do this automatically,
> the last time I tried, I came up with this:
>
> #include <stdio.h>
> #include <pwd.h>                        /* for getpwent */
> int main () {
>   struct passwd * passwd_ptr;         /* password struct */
>   char *comma;
>   char  mvs_uname[21];                  /* prgmr name limited to 20 chars */
>   passwd_ptr =
>     (struct passwd*)getpwuid(getuid()); /* get password struct */
>   strncpy(mvs_uname, passwd_ptr->pw_gecos,
>           sizeof(mvs_uname));         /* get name */
>   mvs_uname[20] = '\0';               /* set max len */
>   comma = (char *)strpbrk(mvs_uname, ",");    /* find first comma */
>   if (comma != NULL) {                /* If there is a comma */
>     *comma = '\0';                    /* change comma to null */
>   }
>   printf("%s\n", mvs_uname);
> }
>
> I think this is doable in Perl, but I don't think shell is any good for
> it.

grep '^[^:]*:[^:]*:'`id|awk -F'[\=\(]' '{print $2}'`: /etc/passwd |
    awk -F: '{print $5}' |
    awk -F, '{print $1}'

    The "grep" selects a line from passwd, "awk -F:" extracts the pw_gecos
field, and "awk -F," truncates everything after first "," (if any).

    All you have to do is assign the result to variable, the only problem is
need in nested backticks.  If memory serves me right, modern shells support
a '$(cmd)' nestable replacement for backticks, but it is supported not on
all platforms (IRIX's & Linux's /bin/sh understand it, Solaris and OSF --
don't).  The problem can be solved by obtaining the inner `` into a variable
first (UID=`id|awk...`) and using the $UID in the grep.

       ___________________________________________________________________
       Dmitry Yu. Bolkhovityanov  |  Novosibirsk, RUSSIA
       phone (383-2)-39-49-56     |  The Budker Institute of Nuclear Physics
                                  |  Lab. 5-13
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dominik Vogt <[email-masked]>
Date: Mon, 9 Apr 2001 10:03:46 +0200

> field, and "awk -F," truncates everything after first "," (if any).

This one is much simpler:

  grep "^`whoami`:" /etc/passwd | cut -f 5 -d ":"

But anyway, since the comment field can contain other information
than the user name, and it's not much effort to set the variable
once manually, it's not worth the effort, I think.

 $ man 5 passwd

   ...
   The  comment  field  is  used by various system utilities,
   such as finger(1).  Three additional values may be present
   in the comment field.  They are

        pri= - set initial value of nice

        umask= - set initial value of umask

        ulimit= - set initial value of ulimit

   These  fields  are  separated from each other and from any
   other comment field by a comma.
   ...

For Emacs/XEmacs users it should be possible to extract the
ChangeLog name and email address from the config file.

 ...
 '(add-log-full-name "Dominik Vogt")
 '(add-log-mailing-address "[email-masked]")
 ...

Bye

Dominik ^_^  ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Mon, 09 Apr 2001 07:20:52 -0400

...
>   grep "^`whoami`:" /etc/passwd | cut -f 5 -d ":"

None of this works for me.
Not all UNIX systems put an entry in /etc/passwd for
the user.

--
Dan Espen
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854                     Phone: (732) 699-5570
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]