From 3a9241add947cb6d24b5de7a8927517426a78795 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 25 Aug 2012 14:25:22 -0500 Subject: Move commands into "posix", "lsb", and "other" menus/directories. --- toys/other/w.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 toys/other/w.c (limited to 'toys/other/w.c') diff --git a/toys/other/w.c b/toys/other/w.c new file mode 100644 index 00000000..50f2283b --- /dev/null +++ b/toys/other/w.c @@ -0,0 +1,36 @@ +/* vi: set sw=4 ts=4: + * + * w.c - shows logged in users + * + * Copyright 2012 Gaurang Shastri + * + * Not in SUSv4. + +USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN)) + +config W + bool "w" + default y + help + usage: w + + Show who is logged on and since how long they logged in. +*/ + +#include "toys.h" + +void w_main(void) +{ + struct utmpx *x; + + xprintf("USER TTY LOGIN@ FROM"); + setutxent(); + while ((x=getutxent()) != NULL) + if (x->ut_type==7) { + time_t tt = x->ut_tv.tv_sec; + + xprintf("\n%-9.8s%-9.8s %-4.24s (%-1.12s)", x->ut_user, x->ut_line, + ctime(&tt), x->ut_host); + } + xputc('\n'); +} -- cgit v1.2.3