jiabin79 发表于 2004-3-9 16:03:07

在c语言里怎么调用linux命令

如下:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include &lt;sys/types.h&gt;

int main(void)
{
printf("real uid=%d, effective uid=%d\n",getuid(),geteuid());
exit(0);
user_id_t uid;
uid=geteuid();
setuid(uid);
//我想在这里调用linux的setup命令
return 0;

}

jiabin79 发表于 2004-3-9 16:20:17

system function


The system function is used to issue a command. Execution of your program will not continue until the command has completed.


Library:   stdlib.h

Prototype: int system(const char *cmd);

Syntax:    system( "cat /etc/hosts");

Notes:
         In Unix systems, the command is passed to "/bin/sh -c" for
         execution. I do not know what handles the command in DOS systems.
页: [1]
查看完整版本: 在c语言里怎么调用linux命令