我想在python脚本中将“dd”命令的输出重定向到stdout。这是我的代码:
def dd2pipe():
chunk=654321
skip_ntimes= 2
read_ntimes= 3
filepath='39476a90-a5f1-cd59-7a8d-34c016276514.high.mp3'
p1_cmds = [f'dd bs={chunk}',
f'skip={skip_ntimes}',
f'count={read_ntimes}',
f'if={filepath}']
p1 = sp.Popen(p1_cmds,shell=True, stdout=sp.PIPE, stderr=sp.STDOUT)
byte_data= p1.stdout.read()
p1.stdout.close()
p1.wait()
print(byte_data)
dd2pipe()
我得到的结果是:
b'0+0 records in\n0+0 records out\n0 bytes copied, 2,338e-05 s, 0,0 kB/s\n'
你能帮我读一下STDOUT中dd命令的字节吗
多亏了Ry-s的回答,它才有效。我将shell更改为False,将p1_cmds更改为:
相关问题 更多 >
编程相关推荐