QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1250|回复: 1

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

[复制链接]
发表于 2004-3-9 16:03:07 | 显示全部楼层 |阅读模式
如下:
#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;

}
 楼主| 发表于 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.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-10 12:27 , Processed in 0.043542 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表