1: #!/usr/bin/perl -w
   2: # Perform some action on your exit from the last tty you are logged on.
   3: # I use it to close fetchmail from .bash_logout (I start it from
   4: # .bash_profile)
   5: # Sorry for any mistakes - it's my first post...
   6: 
   7: open(MY_IN, 'users|') or die "No possibility to read from the stream.\n";
   8: $line = <MY_IN>;
   9: close MY_IN;
  10: chomp $line;
  11: @sus = split / /, $line;
  12: foreach (@sus) {
  13:   if ($_ eq "pfm") { $num++; }
  14: }
  15: if ($num eq 1) {
  16:   exec "fetchmail --quit";
  17: }