我有一段python代码,我需要将它转换为perl,但不幸的是我不擅长perl,如果问题很简单,很抱歉。我想检查 STDOUT 和 STDERR 的特定单词。这是python代码:
p = subprocess.Popen("bmod -b " + beginTime + " " + job_id + "; exit 1;",
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
while p.poll() is None:
err = p.stderr.readline().decode('utf_8')
out = p.stdout.readline().decode('utf_8')
if "changed" in err or "changed" in out:
subprocess.Popen("echo rescheduling was successful!", shell=True)
os._exit(0)
我阅读了一些文档,open3 函数可能在这里工作,但对于 p.poll() 部分,我不确定该使用什么。