删除标准输出 [英] redicting standard output

查看:78
本文介绍了删除标准输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我在其中创建一个Plink进程,用HP Unix盒子进行通信。我遇到的问题是,在阅读

重定向输出时,它似乎试图继续结束并获得无限循环中的
。我正在检查输出的结束

是这样的:


while((hj = puttyProcess.StandardOutput.ReadLine())!= null)


我做错了什么?


谢谢,


Zenon

解决方案

Zenon写道:

我有一个应用程序,我创建一个Plink进程与HP Unix进行通信框。我遇到的问题是,在阅读
重定向输出时,它似乎试图继续经过结束并被无限循环捕获。我正在检查输出的结束
这样:

while((hj = puttyProcess.StandardOutput.ReadLine())!= null)

什么我做错了吗?




你的意思是什么?继续走到尽头?


注意你应该也是在另一个线程中读取StandardError,

否则你可能会在尝试向stderr写入

时结束plink阻塞。


Jon


我想我假设线程正在读取空值

表示输出结束并被抓到那里。我怎么用
将StandardError读入另一个帖子?


感谢您的帮助


Z


Jon Skeet [C#MVP]写道:

Zenon写道:

我有一个应用程序,我创建一个Plink进程进行通信
使用HP Unix机箱。我遇到的问题是,在阅读
重定向输出时,它似乎试图继续经过结束并被无限循环捕获。我正在检查输出的结束
这样:

while((hj = puttyProcess.StandardOutput.ReadLine())!= null)

什么我做错了吗?



你是什么意思继续走到尽头?

请注意,你也应该在另一个线程中读取StandardError,
否则你可能会在尝试写stderr时结束plink阻塞。

Jon



< br>

Zenon< ze **** @ comcast.net>写道:

我想我假设线程正在读取空的
表示输出的结束并被抓到那里。


您有什么证据?你确定它不仅仅是因为plink还没有完成阻止吗?

如何将StandardError读入另一个线程?



创建一个可以访问Process引用的新线程,并且与你为StandardOutput做的完全相同,但对于

StandardError。


-

Jon Skeet - < sk *** @ pobox.com>
< a rel =nofollowhref =http://www.pobox.com/~skeettarget =_ blank> http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet

如果回复该组,请不要给我发邮件


I have an application where I create a Plink process to communicate
with an HP Unix box. The problem I am having is that while reading the
redirected output, it seems to try to continue past the end and gets
caught in an endless loop. I am checking for the end of the output
like this:

while ((hj = puttyProcess.StandardOutput.ReadLine())!=null)

What am I doing wrong?

thanks,

Zenon

解决方案

Zenon wrote:

I have an application where I create a Plink process to communicate
with an HP Unix box. The problem I am having is that while reading the
redirected output, it seems to try to continue past the end and gets
caught in an endless loop. I am checking for the end of the output
like this:

while ((hj = puttyProcess.StandardOutput.ReadLine())!=null)

What am I doing wrong?



What do you mean by "continue past the end"?

Note that you should also be reading StandardError in another thread,
otherwise you could end up with plink blocking when it tries to write
to stderr.

Jon


I guess that I was assuming the thread was reading past the null which
signifies the end of the output and getting caught there. How do I
read StandardError into another thread?

thanks for your help

Z

Jon Skeet [C# MVP] wrote:

Zenon wrote:

I have an application where I create a Plink process to communicate
with an HP Unix box. The problem I am having is that while reading the
redirected output, it seems to try to continue past the end and gets
caught in an endless loop. I am checking for the end of the output
like this:

while ((hj = puttyProcess.StandardOutput.ReadLine())!=null)

What am I doing wrong?



What do you mean by "continue past the end"?

Note that you should also be reading StandardError in another thread,
otherwise you could end up with plink blocking when it tries to write
to stderr.

Jon




Zenon <ze****@comcast.net> wrote:

I guess that I was assuming the thread was reading past the null which
signifies the end of the output and getting caught there.
What evidence did you have for that? Are you sure it isn''t just
blocking because plink hasn''t finished?
How do I
read StandardError into another thread?



Create a new thread which has access to the Process reference, and do
exactly the same as you''re doing for StandardOutput, but for
StandardError.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


这篇关于删除标准输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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