Szia!
> A last parancs kimenetét szeretném feldolgozni (debian), de a
> felhneveket csak 8 karakter hosszan hozza. - ez az ami nem jó -
> A wtmp fájlban pedig benne van a teljes név, kapcsolót nem találtam, más
> programot sem.
> Valami ötlet?
Osszedobtam neked egyet:
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <utmp.h>
int main(void) {
struct utmp * utmp;
setutent();
printf("Ty PID Line ID User "
"Last login Host\n"
"-- ------ ---------- ---------- ---------------- "
"--------------------- --------\n");
do {
char utmp_id[sizeof(utmp->ut_id)+1];
struct tm * tm;
char datebuf[64];
utmp=getutent();
if (utmp==NULL)
break;
strncpy(utmp_id,utmp->ut_id,sizeof(utmp->ut_id));
utmp_id[sizeof(utmp->ut_id)]=(char)0;
tm=localtime(&utmp->ut_tv.tv_sec);
strftime(datebuf,sizeof(datebuf),"%a %Y-%m-%d, %H:%M",tm);
printf("%2d %6d %-10s %-10s %-16s %-21s %s\n",
utmp->ut_type,utmp->ut_pid,utmp->ut_line,utmp_id,utmp->ut_user,
datebuf,utmp->ut_host);
} while (1);
endutent();
return (0);
}
_________________________________________________
linux lista - [email protected]
http://mlf2.linux.rulez.org/mailman/listinfo/linux