Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

system last boot, in C

Name: Anonymous 2007-04-07 17:07 ID:X+5rb0Y3

i'm programming in C to output the time of the system's last boot (linux).

can't read from /var/log/ since i don't have permission.

halp plz.

Name: Anonymous 2007-04-07 17:18 ID:a1GWDHro

Use a privilege elevation exploit?

Name: Anonymous 2007-04-07 17:26 ID:WMhahvCM

doesn't time() return the number of milliseconds since system boot?

Name: Anonymous 2007-04-07 17:29 ID:X+5rb0Y3

i can go to /proc/uptime and read it from there

but is there a way for it to show the time in format of day hour:min:sec?

the btime in /proc/stat shows the seconds since 1/1/1970 till the time it was last booted, but thats not helping much..

=((

Name: Anonymous 2007-04-07 17:40 ID:LgTdwhp1

OH LAWD U NEED SUM DIVISION AND SUM SUBTRACTION

Name: Anonymous 2007-04-07 17:41 ID:Heaven

YOU ARE EITHER STUPID OR TROLLING

I SHIT ON THIS THREAD

Name: Anonymous 2007-04-07 17:53 ID:vMi0odE+

    main(){system("uptime");}

problem solved!

Name: Anonymous 2007-04-07 18:02 ID:E4i+O3VA

>>4
man localtime
man strftime

Name: Anonymous 2007-04-07 18:03 ID:Heaven

>>7
Did you even read the question?

Name: Anonymous 2007-04-08 12:02 ID:BQV/aUeF

>>4
>>5 said it clearly : UH NU U WIL HAF 2 DUE SUM SUBTRACTIONS

time(NULL)

Name: Anonymous 2007-04-10 7:30 ID:EYv3C93O

INT GetTimeFromLastBoot(NULL, NULL, NULL, (LPCSTR *) "0", NULL, NULL, NULL);

Name: Anonymous 2007-04-10 7:45 ID:qcZtIzEr

Heres the win32 api version GetTimeFromLastBoot(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
);

Name: Anonymous 2007-07-27 20:33 ID:D++yz7Yp

/*
 *  lastboot.c
 *
 *  $Id: lastboot.c,v 1.00 2007/07/28 01:30:00 prog Exp $
 *
 *  Copyright (C) 2007 by 4chan's /prog/ <http://dis.4chan.org/prog/>;
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>;.
 */

#include <stdio.h>
#include <time.h>

int main(void)
{
        int uptime, ret;
        time_t t;
        FILE * f;

        f = fopen("/proc/uptime","r");
        if (!f)
        {
                perror("cannot open /proc/uptime");
                return 1;
        }

        ret = fscanf(f, "%u", &uptime);
        if (ret==EOF)
        {
                perror("cannot read /proc/uptime");
                return 2;
        }
        if (ret!=1)
        {
                puts("/proc/uptime has bad format");
        }

        fclose(f);

        t = time(0)-uptime;
        printf("System last booted: %s\n", ctime(&t));

        return 0;
}

Name: Anonymous 2007-07-27 21:45 ID:oTy/Qegg

Name: Anonymous 2007-07-27 21:50 ID:oTy/Qegg

Name: Anonymous 2007-07-27 21:53 ID:D++yz7Yp

>>14
>>15

Sir, you appear to be infringing my copyright for lulz. Carry on.

Name: Anonymous 2007-07-27 23:00 ID:Heaven

gpl 3? fucking fail

Name: Anonymous 2007-07-27 23:37 ID:w1uKoPyA

>>16

What? No infringement is being made.

Perhaps you should read your copyright license.

Name: Anonymous 2007-07-28 0:24 ID:0i1pTPWk

Name: Anonymous 2007-07-28 0:28 ID:durfAr7K

this is even better than libclear!

Name: Anonymous 2007-07-28 9:40 ID:jIqtn12f

Damn, they rejected it from freshmeat. Maybe I didn't put a good enough description in.

Name: Anonymous 2007-07-29 20:02 ID:iC8lyqud

Oh well, fail

Name: Anonymous 2007-07-31 7:07 ID:XAWPkri9

>>13
Not POSIX-compliant. Fail.

Name: Anonymous 2008-02-22 12:54

Name: Anonymous 2009-03-06 13:39


Fags galore Due to faulty RAM You   want No reason   for confusion there.

Name: Anonymous 2010-01-20 8:06

>>25
I'm new and what is this?

Name: Anonymous 2010-12-09 20:00

<

Name: Anonymous 2010-12-17 1:37

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2010-12-17 1:38

Erika once told me that Xarn is a bad boyfriend

Name: Anonymous 2011-02-03 2:47

Name: Sgt.Kabu၏蹡kiman扺 2012-05-29 0:03

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List