This is a discussion on Detecting run levels within the HP-UX Operating System forums, part of the Unix Operating Systems category; --> Is there some way to detect run levels programmatically? I see no library functions or system calls that return ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Dan Koren wrote: > Is there some way to detect run > levels programmatically? I see > no library functions or system > calls that return information > about the current system run > level. Have I missed something? Run "who -r". Its output will tell you the run level. If you need to do this from some compiled language, you can use popen() and then parse the output yourself. From the shell, it's pretty easy: just do something like this: runlevel () { set `who -r` echo "$3" } Then you can do echo "The runlevel is `runlevel`." Also, if you do "truss who -r", it seems to read /var/adm/utmpx and read /etc/inittab. So, you might be able to do something involving reading /var/adm/utmpx by calling getutxent(). However, it seems safer to just read the output of "who -r" to me... - Logan |
| |||
| OK, thanks. dk "Logan Shaw" <lshaw-usenet@austin.rr.com> wrote in message news:KVP0e.29568$Ux.3522@tornado.texas.rr.com... > Dan Koren wrote: >> Is there some way to detect run >> levels programmatically? I see >> no library functions or system >> calls that return information >> about the current system run >> level. Have I missed something? > > Run "who -r". Its output will tell you the run level. > > If you need to do this from some compiled language, > you can use popen() and then parse the output yourself. > > From the shell, it's pretty easy: just do something like this: > > runlevel () > { > set `who -r` > echo "$3" > } > > Then you can do > > echo "The runlevel is `runlevel`." > > Also, if you do "truss who -r", it seems to read /var/adm/utmpx > and read /etc/inittab. So, you might be able to do something > involving reading /var/adm/utmpx by calling getutxent(). However, > it seems safer to just read the output of "who -r" to me... > > - Logan |
| |||
| <barts@smaalders.net> wrote in message news:1111736443.771703.165190@l41g2000cwc.googlegr oups.com... > > What are you trying to do? Somewhat devious things as usual. > > Run levels are a pretty nebulous thing in general; Got that... dk |
| ||||
| Hi Dan > Is there some way to detect run > levels programmatically? I see > no library functions or system > calls that return information > about the current system run > level. Have I missed something? As Logan Shaw described, man 4 utmp and man 3c getut should be good starting points. Pay attention: This tells you in which runlevel the system should(!) to be. Not whether all rc-scripts and inittab-stuff worked fine (which is the finally essential thing!). Florian |
| Thread Tools | |
| Display Modes | |
|
|