954,249 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

update System time permanently in solaris

...how to update system time permanently in solaris through c++.
...how can i login into superuser(su) account through c++ code in solaris.

narlapavan
Newbie Poster
20 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

Short answers,

1. Same as you would in a C application.
2. Ditto - you can't.

Long answers.

1. Why? Call system("ntpdate ntp_server_address") - this will set the system time to the global clock. Guaranteed accurate. If you want to set it to your own value, use system("date date+time_value").
2. The problem here is that you will need to input the password for the root account, and that cannot be done if the process is being run in the background. So, for security reasons, you really can't do that. In a shell, running the command "su -" will request the password for the root account, and if the calling process is backgrounded (no stdin), then it will fail.

rubberman
Posting Virtuoso
1,559 posts since Mar 2010
Reputation Points: 277
Solved Threads: 178
 

Actually i brought date from GPS device now i need to set that date every time when i interact with GPS device in mu project

narlapavan
Newbie Poster
20 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

Well, you can enable the setuid bit on the date command (chmod +s /bin/date), then use the system("date time_val") to set the date+time in your C/C++ program.

rubberman
Posting Virtuoso
1,559 posts since Mar 2010
Reputation Points: 277
Solved Threads: 178
 

idea what u have give worked for me, but slight different i.e at the time of installing OS we need to do chmod +s /usr/bin/date command at super user ...
after doing this, we can change from any user ....

thank you for ur suggestions

narlapavan
Newbie Poster
20 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

how can I change 24hr format of time to 12hr format in Solaris 9 permanently

dpa.clt
Newbie Poster
1 post since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: