DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD Ports and Packages

FreeBSD Ports and Packages Installation and upgrading of ports and packages on FreeBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 29th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default Get sysctl value from a C program

Hi!

I was wondering how could I get/set a sysctl value from a C program. For example I want to get the value of 'sysctl kern.osrelease' or something else.. For setting env variables I could use setenv() or getenv(), but can I get the value of a sysctl string from a C program and how?

Thanks!

EDIT:
I've found it, I must have missed the sysctl() prototype in sys/sysctl.h. After reading the sysctl(3) man page gave me the needed results

Last edited by DNAeon; 29th September 2008 at 10:45 AM.
Reply With Quote
  #2   (View Single Post)  
Old 29th September 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,067
Thanked 198 Times in 156 Posts
Default

See sysctl(3).
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #3   (View Single Post)  
Old 29th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default

Thanks, Carpetsmoker, but I've found it after a short time after I posted to the forum - that's why I've edited my post above
Reply With Quote
  #4   (View Single Post)  
Old 29th September 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,067
Thanked 198 Times in 156 Posts
Default

pfff, you actually expect me to read your complete post ... :-/
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to learn to program under BSD? Sunnz Programming 5 24th December 2008 11:45 PM
Learning how to program Solaris_Delta Programming 9 24th December 2008 07:58 PM
run linux's program johnzlly OpenBSD General 38 8th November 2008 12:10 PM
sysctl and cpu information and temperature neurosis FreeBSD General 11 22nd October 2008 09:16 PM
Problem with lid switch Inspiron 1300 sysctl: unknown oid 'hw.acpi.video.lcd0.active' pax FreeBSD General 2 6th August 2008 11:49 AM


All times are GMT. The time now is 01:14 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick