#!/usr/bin/env mwnci include("pwd") cli_args=shift(ARGV) if (len(cli_args) == 0) { println("Usage: ", PROGNAME, "...") exit(1) } foreach user in cli_args { office="" office_phone="" home_phone="" real_name=user pw=getpwent(user) if (len(pw) == 0) { println(PROGNAME, ": Unknown user: ", user) } else { if (len(pw["Gecos"]) > 0) { if (pw["Gecos"][0]) {real_name=pw["Gecos"][0]} if (pw["Gecos"][1]) {office=pw["Gecos"][1]} if (pw["Gecos"][2]) {office_phone=pw["Gecos"][2]} if (pw["Gecos"][3]) {home_phone=pw["Gecos"][3]} office_line=trimprefix(office + ", " + office_phone, ", ") office_line=trimsuffix(office_line, ", ") } printf("Login: %-33sName: %s\n", pw["User"], real_name) printf("Directory:%-30sShell: %s\n", pw["Home"], pw["Shell"]) if (len(office_line) > 0) { printf("Office: %-32s", office_line) } if (len(home_phone) > 0) { println("Home Phone: ", home_phone) } logged_in=false user_who=split(system("who"),"\n") foreach line in user_who { fline=fields(line) if (fline[0] == user) { printf("On since %s %s %s on %s\n", fline[2], fline[3], fline[4], fline[1]) logged_in=true } } if (!logged_in) { cmd=sprintf("last %s | head -1", user) user_last=trim(system(cmd)) if (len(user_last) == 0) { println("Never logged in.") } else { fline=fields(user_last) printf("Last login %s %s %s %s on %s\n", fline[2], fline[3], fline[4], fline[5], fline[1]) } } PLAN=sprintf("%s/.plan", pw["Home"]) PROJECT=sprintf("%s/.project", pw["Home"]) if (file(PROJECT)) { println("Project:\n", cat(PROJECT)) } if (!file(PLAN)) { println("No plan.") } else { println("Plan:\n", cat(PLAN)) } println() } }