> Does anyone know of a way that I can figure out how long a given computer
> has been connected to a network interface? I want to be able to check to
> see how long my PPP connection has been up. ;)
As Attachment there's a little program from me which counts the time after
calling it. Only start it when you dial in and stop it when you'll dial
out.
-Dan
Dan Knapp: C/C++ Developer
eMail: [EMAIL PROTECTED]
Member: FPSGE http://fpsge.notrix.de
Member: OGRE http://www.teamtnt.com/ogre
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#define SEC_PRO_TAG (24*60*60)
#define SEC_PRO_STUNDE (60*60)
#define SEC_PRO_MINUTE (60)
#define SEC_PRO_SEKUNDE (1)
int main (void)
{
time_t startzeit;
time_t differenz;
long tage, stunden, minuten, sekunden;
startzeit = time(NULL);
while (1)
{
sleep(1);
differenz = time(NULL) - startzeit;
differenz -= (tage = differenz / SEC_PRO_TAG) * SEC_PRO_TAG;
differenz -= (stunden = differenz / SEC_PRO_STUNDE) * SEC_PRO_STUNDE;
differenz -= (minuten = differenz / SEC_PRO_MINUTE) * SEC_PRO_MINUTE;
differenz -= (sekunden = differenz / SEC_PRO_SEKUNDE) * SEC_PRO_SEKUNDE;
printf("%d Tage %d Std. %d min. %d sec.\n", tage, stunden, minuten, sekunden
);
if (differenz)
{
printf( "bogus result of calculation, exiting...\n" );
exit(1);
}
}
/* Never reached */
exit(0);
}