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

7 Years
Discussion Span
Last Post by dpa.clt

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.


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


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.


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


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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.