How to get system information

How to get system information

Post by Akshay Ballarpu » Fri, 01 Oct 2004 16:33:48



How to get hardware information on linux machine using system calls ,function
c code
 
 
 

How to get system information

Post by Henrik Carlqvis » Sat, 02 Oct 2004 05:22:08



> How to get hardware information on linux machine using system calls ,function
> c code

fp=popen("cat /proc/cpuinfo /proc/pci /proc/meminfo", "r");
while(fgets(buf, BUFSIZE-1, fp))
  /* Do something with info in buf */ ;
pclose(fp);

regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc2(at)uthyres.com Examples of addresses which go to spammers:


 
 
 

How to get system information

Post by Henrik Carlqvis » Sat, 02 Oct 2004 05:31:25



> fp=popen("cat /proc/cpuinfo /proc/pci /proc/meminfo", "r");

Whoops, sorry about that example. A better practice would be to give the
complete path of the program called:

fp=popen("/usr/bin/cat /proc/cpuinfo /proc/pci /proc/meminfo", "r");

regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc2(at)uthyres.com Examples of addresses which go to spammers:

 
 
 

1. getting the network interface information and default gateway information ??

hi,
  iam trying to get the network interface information and the default
information.After doing some googling i found out the relevant
structures and the ioctl calls for getting the interfaces information(
i suppose i have all that right).
struct ifconf(and using the ioctl SIOCGIFCONF).
there is another structure
struct ifreq
but i dont think i need that one.

Now how do i do to get the interface address(aliases also).i have
written a small program, but dont know where iam going wrong.the code
is

#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <net/if.h>
#include <netinet/in.h>

int
main(int argc, char* argv[])
{
    struct ifconf ifc;
    struct ifreq *ifr;
    struct sockaddr_in *sin;
    char buf[128];

    if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
        perror("socket");
        return 1;
    }

    ifc.ifc_buf = buf;
    ifc.ifc_len = sizeof(buf);
    if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
        perror("ioctl SIOCGIFCONF");
        return 1;
    }

    ifc.ifc_len /= sizeof(struct ifreq);
    for (i=0; i<ifc.ifc_len; i++) {
        ifr = (struct ifreq *) &ifc.ifc_req[i];
        sin = (struct sockaddr_in *) &ifr->ifr_addr;
        printf("%s \n",sin->sin_addr);
        }
    }
    return 0;

And how can i get the default gateway address within my program.

any help will be highly appreciated.

thanks
rohit

2. vmware error

3. looking for information on how to query a pc for system hardware information

4. 16bit Colour with olvwm

5. Netscape on Linux

6. Need information about system-users and system-groups

7. Xarchie problems (compiling)!!!

8. getting system date/time from another system

9. Need help getting Solaris information for a Linux sysadm

10. Getting eth0 device information in C or perl.

11. Getting status information from network interface

12. Help - Getting prtconf information