where to start programming....

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

where to start programming....

Postby sherwani » Tue Jun 13, 2006 2:04 pm

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
sherwani
Cadet
 
Posts: 4
Joined: Mon Mar 06, 2006 5:14 pm
Location: Karachi

Postby farhantoqeer » Thu Jun 15, 2006 8:27 am

use any IDE like Kdevelop, Ajunta / Editor OR

Code: Select all

man gcc
A: Yes
Q: Is top-posting bad?
farhantoqeer
Major General
 
Posts: 917
Joined: Thu Jun 27, 2002 5:45 pm
Website: http://www.emergen.biz
Location: Karachi

Re: where to start programming....

Postby nomankhn » Sat Jun 17, 2006 9:57 am

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
nomankhn
Colonel
 
Posts: 714
Joined: Wed Aug 07, 2002 8:00 pm

Re: where to start programming....

Postby lambda » Sat Jun 17, 2006 6:04 pm

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.
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore

Postby fawad » Sat Jun 17, 2006 6:51 pm

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.
fawad
Site Admin
 
Posts: 918
Joined: Wed Aug 07, 2002 8:00 pm
ICQ: 17672437
Website: http://www.fawad.net
WLM: fawadhalim@hotmail.com
Yahoo Messenger: fawad2048
AOL: fawadhalim
Location: Addison, IL

Postby nomankhn » Tue Jun 20, 2006 12:10 pm

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
nomankhn
Colonel
 
Posts: 714
Joined: Wed Aug 07, 2002 8:00 pm

Re: where to start programming....

Postby Ihtesham » Tue Jul 18, 2006 7:15 pm

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
Ihtesham
Cadet
 
Posts: 6
Joined: Tue Jul 18, 2006 1:40 pm
Website: http://ali.pkdn.net/
Location: Rawalpindi


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron