Image

Imagefd0man wrote in Imagelinux

In case anyone might be interested...

So, I was working on something today - I wanted to just get a simple list of the time people spend on my Linux box, so I wrote a shell script, but found out that since one of my users has a logon longer then 8 characters, it didn't work. Spent a while looking for an apprproate flag or option or something to make '/usr/bin/last' show me more then 8 chars, and finally figured there wasn't any and went in modified the thing. It was quite a bit easier then I thought....

But, anyway, I will supply the patch here in case anyone figures they have the same dilema, or similar and wants to use it:

--- src/last.c~ 2004-07-30 08:16:26.000000000 -0400
+++ src/last.c  2005-11-01 15:28:16.000000000 -0500
@@ -451,19 +451,19 @@
 #endif
                if (!altlist) {
                        snprintf(final, sizeof(final),
-                               "%-8.8s %-12.12s %-16.16s "
+                               "%-12.12s %-12.12s %-16.16s "
                                "%-16.16s %-7.7s %-12.12s\n",
                                p->ut_name, utline,
                                domain, logintime, logouttime, length);
                } else {
                        snprintf(final, sizeof(final),
-                               "%-8.8s %-12.12s %-16.16s %-7.7s %-12.12s %s\n",
+                               "%-12.12s %-12.12s %-16.16s %-7.7s %-12.12s %s\n",
                                p->ut_name, utline,
                                logintime, logouttime, length, domain);
                }
        } else
                snprintf(final, sizeof(final),
-                       "%-8.8s %-12.12s %-16.16s %-7.7s %-12.12s\n",
+                       "%-12.12s %-12.12s %-16.16s %-7.7s %-12.12s\n",
                        p->ut_name, utline,
                        logintime, logouttime, length);