IOError:[Errno 13]从Python NamedPip读取时权限被拒绝

2024-06-16 11:30:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个用Powershell编写的NamedPipe服务器和一个用Python编写的NamedPipe客户端。以下是我的名字管道客户:

def namedpipeClient():
    print "Inside NamedPipeClient"
    time.sleep(2)
    f = open(r'\\x.x.x.x\pipe\testpipe', 'r+b', 0)
    i = 1
    n = struct.unpack('I', f.read(4))[0]    # Read str length
    s = f.read(n)                           # Read str
    f.seek(0)                               # Important!!!
    f.close()
    print 'Read:', s
    if (s is None):
        return True
    else:
        return False

我在一台机器上用C语言启动NamedPipeServer,在另一台机器上,我将通过批处理文件运行NamedPipeClient。下面是我的批处理文件运行测试.bat在

^{pr2}$

因此,以这种方式运行可以毫无问题地执行所有操作。在

现在,如果我试图在同一台机器上执行同一批处理文件,但要从通过psexec启动NamedPipeServer的机器远程执行,psexec \\$remoteMachine -i 0 -d Powershell D:\LoadTesting\runTest.bat该批处理文件将被执行,但在f = open(r'\\x.x.x.x\pipe\testpipe', 'r+b', 0)语句中,它会抛出以下错误。在

Inside NamedPipeClient
Traceback (most recent call last):
  File "D:\LoadTesting\SikuliNPClient.py", line 40, in <module>
    namedpipeClient()
  File "D:\LoadTesting\SikuliNPClient.py", line 9, in namedpipeClient
    f = open(r'\\192.168.173.231\pipe\testpipe', 'r+b', 0)
IOError: [Errno 13] Permission denied: '\\\\x.x.x.x\\pipe\\testpipe'

我以同样的用户身份登录了两台机器,它们也有管理员权限。 请帮我弄清楚我的问题。在

提前谢谢!在


Tags: 文件机器readopenprintnamedpipepipeinside