捕获过程的标准输入/ STDERR / STDOUT后,它已经开始,使用命令行? [英] Capture STDIN / STDERR / STDOUT of a process AFTER it's been started, using command line?

查看:133
本文介绍了捕获过程的标准输入/ STDERR / STDOUT后,它已经开始,使用命令行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谢谢!我usercase:我开始一个漫长的互动配置过程(在屏幕说的),然后意识到我需要总是回答'不',直到我看到某个关键字。好像是浪费时间用手工做到这一点(不是说我可以很容易错过关键词..)

Thanks! My usercase: I started a lengthy interactive 'configure' process (say under 'screen'), and then realised I need to always answer 'no' until I see a particular keyword. Seems a waste of time to do this by hand (not to say that I can easily miss the keyword..)

这样看来我要管STDERR / STDOUT(副本)到过滤器,
并且还能够注入A(控制台)过程的标准输入,
之后,它已经开始,使用命令行?是否有一个现成的解决方案?

Thus it seems I want to pipe (a copy of) STDERR / STDOUT to a filter, and also be able to inject into the STDIN of a (console) process, AFTER it's been started, using command line? Is there a ready-made solution?

下面的工具似乎帮助。要捕获输出,使用

The following tools seem help. To capture output, use

strace -ewrite -p $PID

这不是干净的(节目如行:写(#)),但工程!
但它是否正确地说,把手UTF8?

It's not that clean (shows lines like: write(#,) ), but works! But does it say handle UTF8 correctly?

要输出重定向,像做

printf '..input..' >/dev/pts/33

不过,目前尚不清楚如何找到正确的设备。

But it is not clear how to find the right device..

推荐答案

在Linux操作系统(Linux的显然专用)解决:

Solved in Linux (apparently Linux-specific):

reptyr -s PID 

附加一个过程到另一终端和/或公开其输入和输出作为管道。

attaches a process to another terminal and/or exposes its input and output as pipes.

这篇关于捕获过程的标准输入/ STDERR / STDOUT后,它已经开始,使用命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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