我正在尝试自动解析最初在 Python 程序中打开的日志文件,以便在我开始从文件本身读取实际行之前,其输出采用人类可读的格式。我该怎么做?
with open('/var/log/audit/audit.log') as audit_raw:
audit_formatted=subprocess.call(["ausearch", "-i", audit_raw])
line = audit_formatted.readline()
当我尝试这样做时的错误消息:
Traceback (most recent call last):
File "./email_script.py", line 29, in <module>
audit_log=subprocess.call(["ausearch", "-i", audit_raw])
File "/usr/lib/python3.6/subprocess.py", line 267, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1275, in _execute_child
restore_signals, start_new_session, preexec_fn)
TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper
白板的微信
相关分类