system call as variabe

R

rudra

i have written a code::
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sys;
int i686;
sys=system("/bin/uname -m");
//printf ("%d",sys);
if (sys==i686){
printf("the syst. 32 bit");
}
else
printf("64but");
}
where i want the output of "system("/bin/uname -m")" as the variable
sys.....to find the machine structure.this procedure is not quite
working. can you people suggest me some way?
 
I

Ian Collins

rudra said:
i have written a code::
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sys;
int i686;
sys=system("/bin/uname -m");
//printf ("%d",sys);
if (sys==i686){
printf("the syst. 32 bit");
}
else
printf("64but");
}
where i want the output of "system("/bin/uname -m")" as the variable
sys.....to find the machine structure.this procedure is not quite
working. can you people suggest me some way?

Lack of whitespace in the code?

The serious answer is system() does not return the value printed by the
command you pass to it.

Check your man pages, then ask about popen() on comp.unix.programmer.
 
V

viza

sys=system("/bin/uname -m");

Systems which provide a uname program will probably provide a uname
system call or library function. Lookup:

man 2 uname (on Linux)
man 3 uname (on BSD)

(just "man uname" will get you the manual page for the uname(1), which is
the application)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,244
Latest member
cryptotaxsoftware12

Latest Threads

Top