由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - [转载] Re: freopen
相关主题
CGI之Perl Script一问System Environment variables in Perl
help on sed为什么time命令无法重定向?
关于emacs一问。command line socket tools
帮帮忙,用C作一个SHELLunix下编译fortran 的错误太多,看不到怎么办?
help!!! pipe programshell script help?
how to redirect error output under unixPerl问题求助 (转载)
How to merge stdout and stderrhow to redirect the output
PERL入门求助50伪币:请教perl代码差错的问题!多谢啦!
相关话题的讨论汇总
话题: freopen话题: args话题: pid话题: stdout话题: ls
进入Unix版参与讨论
1 (共1页)
f***c
发帖数: 281
1
【 以下文字转载自 Programming 讨论区 】
【 原文由 funsc 所发表 】
ok
the code is as follows:
while(1)
{
getcommand(args); //the function is to get a command line and works corrently
pid = fork();
if (pid == 0)
{
fd = freopen("a.txt", "w", stdout);
execvp(args[0], args);
}
else
{
waitpid(pid);
}
}
after i run ls -l > foo, the output has been written to a.txt, as i hoped,
but when i run ls again, the result does not show on screen.
it seems that after i redirect the stdout to the file "
1 (共1页)
进入Unix版参与讨论
相关主题
50伪币:请教perl代码差错的问题!多谢啦!help!!! pipe program
sun SPARCstation 20 questionhow to redirect error output under unix
the path of execvpHow to merge stdout and stderr
question about install lapackPERL入门求助
CGI之Perl Script一问System Environment variables in Perl
help on sed为什么time命令无法重定向?
关于emacs一问。command line socket tools
帮帮忙,用C作一个SHELLunix下编译fortran 的错误太多,看不到怎么办?
相关话题的讨论汇总
话题: freopen话题: args话题: pid话题: stdout话题: ls