mir*_*raj 2 c redirect
如何将execlp输出重定向到文件?例如,我想将输出重定向execlp("ls", "ls", "-l", NULL)到输出文件(例如a.txt).
execlp
execlp("ls", "ls", "-l", NULL)
R..*_*R.. 5
你需要做这样的事情:
int fd = open("output_file", O_WRONLY|O_CREAT, 0666); dup2(fd, 1); close(fd); execlp("ls", "ls", "-l", (char *)0);
归档时间:
14 年,6 月 前
查看次数:
3630 次
最近记录: