Loading ...
Sorry, an error occurred while loading the content.

Re: Sample Program - perl

Expand Messages
  • Cameron Simpson
    ... You can easily write a C program to read the utmp and wtmp files (they are the same format, with utmp being the current logins and wtmp being log of logins
    Message 1 of 15 , Jul 16, 2007
    • 0 Attachment
      On 16Jul2007 05:40, Robert C Wittig <wittig.robert@...> wrote:
      | Felix T. Gomez, Jr. wrote:
      | > Last command is very useful but it would be better if
      | > I will know what file does this information resides?
      | >
      | > What I am thinking is if the data resides in a file, I
      | > could get it by making a perl script that will read a
      | > "log file" and parse it line by line just like how i
      | > could see it when I type the "last" command.
      |
      | 'last' extracts its information from /var/log/wtmp as indicated in the
      | man page for the 'last' command I referred you to, but unfortunately,
      | 'wtmp' is a binary file, which cannot be directly read, which accounts
      | for the existence of 'last', which is the utility created to read from
      | 'wtmp'.

      You can easily write a C program to read the utmp and wtmp files (they
      are the same format, with utmp being the current logins and wtmp being
      log of logins and logouts). See "man 5 utmp".

      It would be easy to have this C program write text output and run like
      "tail -f" (or just read from "tail -f /var/log/wtmp" with a pipe).

      I used to have just such a program hooked up to list my friends in my
      terminal's status line as they logged in and out (a multiuser shared system).

      Cheers,
      --
      Cameron Simpson <cs@...> DoD#743
      http://www.cskk.ezoshosting.com/cs/

      EMACS: Escape Meta Alt Control Shift
    • Cameron Simpson
      ... Oh yes, you don t need the C program either. Fetch the perl User::Utmp module and work from that. Doco:
      Message 2 of 15 , Jul 16, 2007
      • 0 Attachment
        Felix T. Gomez, Jr. wrote:
        | > Last command is very useful but it would be better if
        | > I will know what file does this information resides?
        | >
        | > What I am thinking is if the data resides in a file, I
        | > could get it by making a perl script that will read a
        | > "log file" and parse it line by line just like how i
        | > could see it when I type the "last" command.

        Oh yes, you don't need the C program either. Fetch the perl User::Utmp
        module and work from that. Doco:

        http://search.cpan.org/~mpiotr/User-Utmp-1.8/Utmp.pm

        Cheers,
        --
        Cameron Simpson <cs@...> DoD#743
        http://www.cskk.ezoshosting.com/cs/

        Everything is gone;
        Your life's work has been destroyed.
        Squeeze trigger (yes/no)?
        - Haiku Error Messages http://www.salonmagazine.com/21st/chal/1998/02/10chal2.html
      • cmd_junkie
        ... enable ACPI ... In the future, I d make sure that ACPI is enabled. It s one of the very first options in the kernel configuration menus.
        Message 3 of 15 , Jul 16, 2007
        • 0 Attachment
          --- In LINUX_Newbies@yahoogroups.com, "Gary" <xheralt@...> wrote:
          >
          > It did this just fine under F7 running as a LiveCD demo, but since I
          > made it a permanent install (kernel 2.6.21-1.3228), it doesn't.
          >
          > One note of potential relevence in my bootup messages:
          >
          > ACPI: BIOS age (1997) fails cutoff (1999) acpi=force needed to
          enable ACPI
          >
          > Okay, exactly what am I supposed to insert 'acpi=force' into? Or is
          > the problem somewhere else?
          >

          In the future, I'd make sure that ACPI is enabled. It's one of the
          very first options in the kernel configuration menus.
        • Gary
          ... Well, that is precisely my question -- how do I enable it? I never see the boot prompt anymore, it just flies by, so I can t enter it there. Do I
          Message 4 of 15 , Jul 20, 2007
          • 0 Attachment
            --- In LINUX_Newbies@yahoogroups.com, "cmd_junkie" <cmd_junkie@...> wrote:
            >
            > --- In LINUX_Newbies@yahoogroups.com, "Gary" <xheralt@> wrote:
            > >
            > > It did this just fine under F7 running as a LiveCD demo, but since I
            > > made it a permanent install (kernel 2.6.21-1.3228), it doesn't.
            > >
            > > One note of potential relevence in my bootup messages:
            > >
            > > ACPI: BIOS age (1997) fails cutoff (1999) acpi=force needed to
            > enable ACPI
            > >
            > > Okay, exactly what am I supposed to insert 'acpi=force' into? Or is
            > > the problem somewhere else?
            > >
            >
            > In the future, I'd make sure that ACPI is enabled. It's one of the
            > very first options in the kernel configuration menus.
            >
            Well, that is precisely my question -- how do I enable it? I never
            see the boot prompt anymore, it just flies by, so I can't enter it
            there. Do I understand correctly that I'm supposed to put the
            acpi=force parameter into grub.conf? Any special formatting I need to
            observe?
          • Gary
            ... It should be noted I haven t actually sat down at said puter and reviewed the info on grub. Yet. Planning to do so Real Soon Now. Will come back later
            Message 5 of 15 , Jul 20, 2007
            • 0 Attachment
              > > In the future, I'd make sure that ACPI is enabled. It's one of the
              > > very first options in the kernel configuration menus.
              > >
              > Well, that is precisely my question -- how do I enable it? I never
              > see the boot prompt anymore, it just flies by, so I can't enter it
              > there. Do I understand correctly that I'm supposed to put the
              > acpi=force parameter into grub.conf? Any special formatting I need to
              > observe?
              >
              It should be noted I haven't actually sat down at said 'puter and
              reviewed the info on grub. Yet. Planning to do so Real Soon Now.
              Will come back later with further questions if this doesn't help.
            Your message has been successfully submitted and would be delivered to recipients shortly.