将数据管道输出到字符串或文件(.piped)
bin_directory/command1
#!/bin/bash
echo hello $1
#!/bin/bash
echo hello $1 1>&2
from commandlib import CommandPath
command_path = CommandPath("./bin_directory")
标准输出到文件句柄
with open("regular", "w") as handle:
command_path.command1("harry").piped.stdout_to_handle(handle).run()
文件“regular”将包含
hello harry
标准输出到文件名
command_path.command1("harry").piped.stdout_to_filename("regular").run()
文件“regular”将包含
hello harry
标准错误到文件句柄
with open("error", "w") as handle:
command_path.command2("tom").piped.stderr_to_handle(handle).run()
文件“error”将包含
hello tom