无法在python scrip中tee shell命令的结果

2024-04-19 15:57:17 发布

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

我试图运行shell命令,将输出转换为python脚本中的某个文件,但是当我看到tee output的日志文件时,它是空的。代码如下所示:

val_home =  os.environ["xyz"]
pwd = os.getcwd()
os.chdir(val_home)
os.chdir("..")
avk_home = os.environ["abc"]
del os.environ['abc']
command = "source %s/somefile/ %s/inputparamater | tee config.log" %(val_home,val_home)
execute(command)#function written to execute shell command ,no issue with this
assert search_string("config.log","Success") ,"Target config failed"
rm_file(['config.log'])
os.environ["AVKRUN_HOME"] = avk_home
os.chdir(pwd)

文件config.out是空的,但是当我手动运行命令时,我看到tee文件输出。你知道吗


Tags: 文件命令logconfighomeospwdenviron