简体   繁体   English

使用cmd.exe或PowerShell或Python从名为pipe的windows中读取

[英]Read from windows named pipe with cmd.exe or PowerShell or Python

I'm looking for a quick way to check which data comes into a named pipe (on windows). 我正在寻找一种快速方法来检查哪些数据进入命名管道(在Windows上)。 Is there any way to do it from cmd.exe or powershell or python? 有没有办法从cmd.exe或powershell或python做到这一点? Actually I found only ways to create named pipe and than manipulate it. 实际上我发现只有方法来创建命名管道而不是操纵它。 But how can I open a named pipe created by another program? 但是如何打开由另一个程序创建的命名管道?

Powershell允许您使用整个.net api,因为您可以在框架中使用管道功能

The client can connect to a Windows named pipe as if it was any other file, provided it has been created by another program. 客户端可以连接到Windows命名管道,就像它是任何其他文件一样,只要它是由另一个程序创建的。 The low-level API is CreateFile using ALWAYS_EXISTING , but the ordinary language routines, like Python's open should work. 低级API是使用ALWAYS_EXISTING CreateFile ,但普通的语言例程,如Python的open应该可以工作。 The filename will be \\\\ server \\pipe\\ name . 文件名为 \\\\ server \\ pipe \\ name Unlike disk files pipes are temporary, and when every handle to a pipe has been closed, the pipe and all the data it contains are deleted, so personally I maintain the pipe using a service where necessary. 与磁盘文件不同,管道是临时的,当管道的每个句柄都已关闭时,管道及其包含的所有数据都将被删除,因此我个人在必要时使用服务来维护管道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM