1: Okay, this is a bit old, but I found it, and it was fun to do ;)) <BR>
2: SUN needed the configuration of our system, I could do it in C<BR>
3: but didn't feel like cutting and pasting everything:<BR>
4: <CODE>
5: #!/usr/bin/perl -w
6: use strict;
7:
8: my (@Variables,@Code);
9:
10: foreach (`man sysconf`)
11: {
12: s/^\s+//;
13: my $Var=(split /\s+/,$_,2)[0] or next;
14: next unless ($Var=~/^_[A-Z_]+$/o);
15: my $Cvar=lc $Var;
16: push @Variables,"long int $Cvar=sysconf($Var);";
17: push @Code,"printf(\"$Var set to: \%d\\n\",$Cvar);";
18: };
19: local $"="\n ";
20:
21: print << "PROGRAM";
22: #include <stdio.h>
23: #include <unistd.h>
24:
25: int main (argc,argv)
26: int argc;
27: char *argv[];
28: {
29: @Variables
30: @Code
31: }
32: PROGRAM
33: </CODE>
34: <BR>
35: Presto!!! redirect to getconf.c, compile, run, be happy....<BR>
36: <BR>
37: I have to add here that this code is NOT <BR>
38: very portable... In this case it didn't need to be... <BR>
39: It was short and worked ([jeroenes] posted an update here, and<BR>
40: I did some updating myself, so this should have made it a bit<BR>
41: more portable (for what I don't know though ;))<BR>
42: <BR>
43: You MAY run into gcc compiling errors, this is a result from labels in<BR>
44: the man page not being in your include file<BR>
45: delete those items ;))<BR>
46: <BR>
47: GreetZ!, <BR><UL>ChOas</UL><BR>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get your system configuration from a man page.
by jeroenes (Priest) on Jan 08, 2001 at 16:23 UTC | |
|
Re: Get your system configuration from a man page.
by jeroenes (Priest) on Feb 05, 2001 at 15:45 UTC | |
|
Re: Get your system configuration from a man page.
by petral (Curate) on Jan 24, 2001 at 01:06 UTC |