本文介绍了如何读/写入Perl中的命名管道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,其输入/输出插入命名管道。我试图写一些东西到第一个命名管道,并从第二个命名管道读取结果,但没有发生。

我使用open然后open2然后sysopen whithout成功:

  sysopen(FH,/ home / Moses / enfr_kiid5 / pipe_CGI_Uniform,O_RDWR); 
sysopen(FH2,/ home / Moses / enfr_kiid5 / pipe_Detoken_CGI,O_RDWR);
打印FH测试4242测试4242或死错误打印;

不会发生错误,但不起作用:我看不到打印的痕迹,测试语句不写入第一个命名管道,并尝试从第二个块读取进程。 解决方案

  $ mkfifo pipe 
$ cat pipe&
$ perl -e'打开我的$ f,>,pipe;打印$ ftest\\\
'
test
$ rm pipe

你真的不需要看起来像 sysopen 的东西,命名管道真的应该像普通文件,虽然是半双工。这与你的代码和我的代码有什么区别,值得研究,如果你真的需要这个开放模式。


I have a script which have their input/output plugged to named pipes. I try to write something to the first named pipe and to read the result from the second named pipe but nothing happen.

I used open then open2 then sysopen whithout success :

sysopen(FH, "/home/Moses/enfr_kiid5/pipe_CGI_Uniform", O_RDWR);
sysopen(FH2, "/home/Moses/enfr_kiid5/pipe_Detoken_CGI", O_RDWR);
print FH "test 4242 test 4242" or die "error print";

doesn't made error but didn't work : i can't see trace of the print, the test sentence is not write into the first named pipe and try to read from the second block the process.

解决方案

Works here.

$ mkfifo pipe
$ cat pipe &
$ perl -e 'open my $f, ">", "pipe"; print $f "test\n"'
test
$ rm pipe

You don't really need fancy sysopen stuff, named pipes are really supposed to behave like regular files, albeit half-duplex. Which happens to be a difference between your code and mine, worth investigating if you really need this opening pattern.

这篇关于如何读/写入Perl中的命名管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 05:45