where to start programming....

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
sherwani
Cadet
Posts: 4
Joined: Mon Mar 06, 2006 5:14 pm
Location: Karachi

where to start programming....

Post by sherwani »

salam
i need help for an assignment in which there is a value stored in a variable which is decreasing with the passage of time. if there is a shut down in system (either normal or abnormal), the current value remains same on next login.
kindly guide me where to start, as i m new in linux but dont send me complete coding. i know little programming in C (windows) just tell me where to start in linux.
thanks
farhantoqeer
Major General
Posts: 917
Joined: Thu Jun 27, 2002 5:45 pm
Location: Karachi
Contact:

Post by farhantoqeer »

use any IDE like Kdevelop, Ajunta / Editor OR

Code: Select all

man gcc
A: Yes
Q: Is top-posting bad?
nomankhn
Colonel
Posts: 714
Joined: Wed Aug 07, 2002 8:00 pm

Re: where to start programming....

Post by nomankhn »

sherwani wrote:salam
i need help for an assignment in which there is a value stored in a variable which is decreasing with the passage of time. if there is a shut down in system (either normal or abnormal), the current value remains same on next login.
kindly guide me where to start, as i m new in linux but dont send me complete coding. i know little programming in C (windows) just tell me where to start in linux.
thanks
Dear sherwani,

its best if you will use bash scripting and GCC (Gnu compiler collection), Daily play 5 to 6 hours on these things than you can understand what u want to do.

Regards
Noman Liaquat Khanzada Rajput
Money is not everything
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Re: where to start programming....

Post by lambda »

sherwani wrote:i need help for an assignment in which there is a value stored in a variable which is decreasing with the passage of time. if there is a shut down in system (either normal or abnormal), the current value remains same on next login.
you can run a program that stores the value in a file, and decreases its value over the passage of time, but you can't do it with an environment variable in a useful way.

please explain why you want to do this so we can find a better solution for you.
fawad
Site Admin
Posts: 918
Joined: Wed Aug 07, 2002 8:00 pm
Location: Addison, IL
Contact:

Post by fawad »

I think he wants to have the counter persist between reboots. Simplest way I can think of is to write it out to a file and read it in on application startup if it exists.
nomankhn
Colonel
Posts: 714
Joined: Wed Aug 07, 2002 8:00 pm

Post by nomankhn »

Dear sherwani,

its better to save your value in current running system and then then don't delete those files, lets power off ur system due to electricity, then u read the file

tmp=`cat /var/xyzvlue`

and then use it where you want to , its better to do bash scripting.

Regards
Noman Liaquat Khanzada Rajput
Money is not everything
"Microsoft isn't evil, they just make really crappy operating systems." - Linus Torvalds
Ihtesham
Cadet
Posts: 6
Joined: Tue Jul 18, 2006 1:40 pm
Location: Rawalpindi
Contact:

Re: where to start programming....

Post by Ihtesham »

sherwani wrote:salam
i need help for an assignment in which there is a value stored in a variable which is decreasing with the passage of time. if there is a shut down in system (either normal or abnormal), the current value remains same on next login.
kindly guide me where to start, as i m new in linux but dont send me complete coding. i know little programming in C (windows) just tell me where to start in linux.
thanks
man gcc as farhantoqeer said. And then you can sleep ;)

Code: Select all

#include <time.h>
 
void sleep(unsigned int millisec)
{
    clock_t goal = millisec + clock();
    while (goal > clock());
}

//Now update value (in file or whatever) each time you call sleep() in loop
Ali
Post Reply