ChinaUnix.net
相关文章推荐:

用管道实现重定向

请教下,想写个程序完成这个目的: 执行一个子进程(如exec("ls")),然后把程序的stdout输出截获到父进程的缓冲区了,linux下没有写过,在win下实现的方案是: 1. 利管道,把子进程的stdout重定向到此管道. 2. 子进程关闭后,父进程从管道读出. linux下可行不?我对linux的管道不是很了解,谢谢各位.

by SirFang - C/C++ - 2006-04-28 09:51:30 阅读(791) 回复(3)

相关讨论

各位大侠, 怎样C/C++实现shell中的重定向管道功能呢? (> , <, | ) 另外,附带再问一个问题, readline库文件在哪个文件夹下面呢? 老师说编译的时候让我们带上这个库文件,是不是需要 g++ -L (库文件的路径/readline.h) xxxx.cpp -0 yyy 这个格式呢? 谢谢了!

by songna - C/C++ - 2008-11-05 14:10:54 阅读(3409) 回复(4)

if(...) header("location:../a.php"); else { ... } 怎么就不行呢

by utopia_wb - PHP - 2003-09-02 22:26:04 阅读(882) 回复(3)

有谁知道管道重定向的区别的, 比如: [code]ls>;foo wc

by whpu000625 - 内核/嵌入技术 - 2005-10-07 09:06:50 阅读(528) 回复(2)

有谁知道管道重定向的区别的, 比如:[code]ls>;foo wc

by whpu000625 - Linux论坛 - 2005-10-06 16:57:16 阅读(323) 回复(0)

一台服务器有两块网卡分别连两个互相隔离的网络:192.168.0.x和192.168.1.x,没有开启路由。 想让从192.168.0.x网段访问该服务器端口8000端口都重定向到192.168.1.x网段里的一台机器的80端口。 该什么工具来实现啊?

by ahocat - BSD - 2008-07-19 22:31:30 阅读(1762) 回复(8)

c語言....寫... 我知道是pipe()...可是不知道怎麼... 假設我要實現是 1. wc < input.txt 2. ls | wc 我的想法是首先我了 1. execvp("wc", "wc"); 開始不知道怎麼重定向了~~ 2. execvp("ls", "ls"); 中間也是不知道怎麼寫啊... execvp("wc", something); execvp("wc", "wc"); 我是一定要上這些去 模妨 shell....但是不知道怎麼將exe出來的結果來 redirection 同 pipe.... [ 本帖最后由 ta...

by takyeyu - C/C++ - 2008-04-13 21:21:57 阅读(1491) 回复(9)

我想写个管道实现进程间信息交互的程序,是这样写的,为什么子进程打印的信息没有显示出来? int main() { int f_des[2],f_des2[2]; int iOout; char sBuf[1024+1]; ssize_t n; if(pipe(f_des)==-1) { perror("pipe"); exit(1);} if(pipe(f_des2)==-1) { perror("pipe"); exit(1);} switch(fork()){ case -1: perror("fork"); exit(2); case 0: iOout=dup(fileno(...

by greenwillow280 - C/C++ - 2008-01-24 20:48:03 阅读(1057) 回复(2)

open(INPUTF, $ARGV[0]) || die("can't open filein:".$ARGV[0]); pipe (INPUTP, OUTPUTP); my $retval = fork(); if ($retval != 0) { # this is the parent process print "father print: my son is ".$retval."\n"; my $line = ""; close (OUTPUTP); while() { $line = $_; print "father print:".$line; if($line =~ m/this\sis\sa\stest/g) { ...

by j4ckl1u - Perl - 2007-11-07 16:10:24 阅读(3855) 回复(3)

如何使组合命令(Compound Command) 1.& Usage:第一条命令 & 第二条命令 [& 第三条命令...] 这种方法可以同时执行多条命令,而不管命令是否执行成功 Sample: C:\>dir z: & dir c:\Ex4rch The system cannot find the path specified. Volume in drive C has no label. Volume Serial Number is 0078-59FB Directory of c:\Ex4rch 2002-05-14 23:51 . 2002-05-14 23:51 .. 2002-05-14 23:51 14 sometips.gif 2.&& Usag...

by 心若在 - 网络技术文档中心 - 2007-06-23 13:06:55 阅读(483) 回复(0)

stdout太大了,想把他重定向到cronolog

by FunBSD - Java - 2007-08-08 20:39:15 阅读(3586) 回复(9)