使用命名管道创建读/写环境 [英] create read/write environment using named pipes

查看:203
本文介绍了使用命名管道创建读/写环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是RedHat EL 4,我使用bash 3.00.15。

I am using RedHat EL 4. I am using Bash 3.00.15.

我写SystemVerilog和我想要模仿stdin和stdout。我只可以使用的文件作为正常stdin和stdout未在环境中的支持。我想使用命名管道来模拟stdin和stdout。

I am writing SystemVerilog and I want to emulate stdin and stdout. I can only use files as the normal stdin and stdout is not supported in the environment. I would like to use named pipes to emulate stdin and stdout.

我知道如何使用mkpipe创建to_sv和from_sv文件,以及如何打开它们,SystemVerilog中使用它们。

I understand how to create a to_sv and from_sv file using mkpipe, and how to open them and use them in SystemVerilog.

通过使用猫> to_sv我可以输出字符串到SystemVerilog的仿真。但也输了我在shell我打字。

By using "cat > to_sv" I can output strings to the SystemVerilog simulation. But that also outputs what I'm typing in the shell.

我想,如果可能的话,单壳它的行为几乎像一个UART终端。无论我去型直接走出去to_sv,而无论是写入from_sv被打印出来。

I would like, if possible, a single shell where it acts almost like a UART terminal. Whatever I type goes directly out to "to_sv", and whatever is written to "from_sv" gets printed out.

如果我会对此完全错误的,然后通过各种手段提出正确的方法!太感谢你了,

If I am going about this completely wrong, then by all means suggest the correct way! Thank you so much,

Nachum Kanovsky

Nachum Kanovsky

推荐答案

修改:您可以输出到一个命名管道,并从其他人在同一终端阅读。您还可以禁用按键使用回显到终端的stty -echo

Edit: You can output to a named pipe and read from an other one in the same terminal. You can also disable keys to be echoed to the terminal using stty -echo.

mkfifo /tmp/from
mkfifo /tmp/to
stty -echo
cat /tmp/from & cat > /tmp/to

白衣你写的这个命令一切按的/ tmp /至,不附和,一切从写入的/ tmp / 将呼应。

Whit this command everything you write goes to /tmp/to and is not echoed and everything written to /tmp/from will be echoed.

更新:我已经找到一种方法来inputed到/ tmp /每字符在同一时间发送给一个。取而代之的猫>的/ tmp /至使用这个命令:

Update: I have found a way to send every chars inputed to the /tmp/to one at a time. Instead of cat > /tmp/to use this command:

while IFS= read -n1 c;
do  
   if [ -z "$c" ]; then 
      printf "\n" >> /tmp/to; 
   fi; 
   printf "%s" "$c" >> /tmp/to; 
done

这篇关于使用命名管道创建读/写环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆