LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to know how long I connected to Internet? (https://www.linuxquestions.org/questions/linux-general-1/how-to-know-how-long-i-connected-to-internet-280114/)

kornerr 01-20-2005 09:43 AM

How to know how long I connected to Internet?
 
How to know how long I connected to Internet?
I use kppp.
I found kppp logs per months, but there is no any info.
Is there exists any way to know it?

masand 01-20-2005 10:14 AM

there is an option of accounting in kppp
lookout there

regards

kornerr 01-20-2005 10:52 AM

I tried, but probably Im too stupid :) But first I had a thought to make shell script. So now I want it no matter if kppp has it. But i need the next:
command to read a file (and if possible to read, e.g. only the 1st line of a file, or only the 2nd).
Does such command exist?

masand 01-20-2005 11:03 AM

please elaborate more on what do u want to do

regards

kornerr 01-20-2005 11:11 AM

kppp has Execute tab to exec apps on connection/disconnction.
I want connect script:
#!/bin/sh
#
(date +%k; date +%M; date +%m)> /apps/conscript/contime
So this writes hour, min, month by different lines.
And I want disconnect script (I dont know how to write it):
#!/bin/sh
#
hour = NecessaryCmd (/apps/conscript/contime, line1)
min = NecessaryCmd (/apps/conscript/contime, line2)
month = NecessaryCmd (/apps/conscript/contime, line3)
Then add hours, mins and so on, then write it to, say, /apps/conscript/stat
Then see how much to pay :)
Does such cmd exist?

masand 01-20-2005 11:35 AM

u need to wriote a scrpt on ur own
i do not think there is command for this

at the maximum u can use the command "grep" for parsing some of the file

regards

kornerr 01-20-2005 12:38 PM

I found how to read a file in cpp (Im a real fool in it). Here is my demo:
#include <fstream.h>
#include <iostream.h>
int main (int argc, char **argv)
{
char string[3];
char next;
ifstream thefile;
thefile.open("/apps/conscript/ass");
for (int i=0;i<3;i++)
{
thefile>>string;
cout<<string;
next=thefile.peek();
if (next=='\n')
cout<<"\n";
}
thefile.close();
return 0;
}

This doesnt do what I want, but... I think I will do it tomorrow (my time is GMT+7; its time to sleep now:)). May be I will post my all working (if they will) scripts and cpp apps.
______
Good night. :)

masand 01-20-2005 12:57 PM

u will learn more on this as u go on developing as u go more into this

regards

stakhous 01-20-2005 01:57 PM

does the command, "uptime" work?

masand 01-20-2005 02:12 PM

uptime is for the system uptime i think
is it for the internet connection/devices also???

regards

rsmccain 01-20-2005 02:47 PM

Quote:

Originally posted by masand
uptime is for the system uptime i think
is it for the internet connection/devices also???

regards

uptime is only for system uptime. It's unrelated to internet connectivity.

masand 01-20-2005 02:57 PM

Quote:

Originally posted by rsmccain
uptime is only for system uptime. It's unrelated to internet connectivity.
thats what i mentioned!!!!

there are no arguments with uptime also
only --v(version)

regards

Genesee 01-20-2005 04:16 PM

couldn't you just run "date" at connect and at disconnect, in seconds format, subtract the two values, and divide to get mins, hrs (60, 3600, etc.)?

kornerr 01-21-2005 09:49 AM

Hmm... great idea, but I almost completed work... but ALMOST! My cpp knowledge is VERY poor, but... I shoud do it. Someday :)
_______
Politics is supposed to be the second oldest profession. I have come to realize that it bears a very close resemblance to the first. -- Ronald Reagan

dylbyrt45 01-21-2005 07:57 PM

If all you are wanting to know is how long you have been connected, try running the system monitor called gkrellm. It not only displays system info, but also displays connection speed, and time connected.


All times are GMT -5. The time now is 10:38 AM.