第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在閱讀實(shí)際行之前,我將如何自動(dòng)解析我打開的 audit.log 文件的語法?

在閱讀實(shí)際行之前,我將如何自動(dòng)解析我打開的 audit.log 文件的語法?

慕運(yùn)維8079593 2021-12-26 15:30:09
我正在嘗試自動(dòng)解析最初在 Python 程序中打開的日志文件,以便在我開始從文件本身讀取實(shí)際行之前,其輸出采用人類可讀的格式。我該怎么做?with open('/var/log/audit/audit.log') as audit_raw:    audit_formatted=subprocess.call(["ausearch", "-i", audit_raw])    line = audit_formatted.readline()當(dāng)我嘗試這樣做時(shí)的錯(cuò)誤消息: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
查看完整描述

1 回答

?
白板的微信

TA貢獻(xiàn)1883條經(jīng)驗(yàn) 獲得超3個(gè)贊

您使用正確的參數(shù)調(diào)用ausearch并解析其輸出。


在這里被盜:用于處理 linux 的 audit.log 的 Python 庫?(這是一個(gè)要求圖書館認(rèn)可的題外問題)并且可能會(huì)從 SO 中消失 - 這就是我決定反對(duì)“重復(fù)”的原因。


方尖碑回答:


import subprocess


def read_audit(before,now,user):

    auparam = " -sc EXECVE"

    cmd = "ausearch -ts " + before.strftime('%H:%M:%S') + " -te " + now.strftime('%H:%M:%S') + " -ua " + user + auparam

    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)

    res = p.stdout.read().decode()

    return res


查看完整回答
反對(duì) 回復(fù) 2021-12-26
  • 1 回答
  • 0 關(guān)注
  • 136 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)