-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbashUtils.py
27 lines (21 loc) · 921 Bytes
/
bashUtils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import subprocess
import time
import json
from subprocess import PIPE, STDOUT
variables=json.load(open(f'variables.json',))
argusConfPath = variables["argusConfig"]
pwd = variables["password"]
def createArgusFilesOutput (dataDir):
print("argus >> txt")
subprocess.run(['bash', f'{argusConfPath}/argus_conversion.sh', f'{argusConfPath}', f'{dataDir}'])
print("argus >> txt DONE")
def createArgusDaemonOutput (outputDir):
subprocess.run(f'echo {pwd} | sudo -S pkill argus', shell=True, capture_output=True)
time.sleep(5)
print("init argus daemon")
subprocess.run(f'echo {pwd} | sudo -S argus -P 561 -d', shell=True, capture_output=True)
time.sleep(5)
print("start netflows capture")
p = subprocess.Popen(f'exec ra -F {argusConfPath}/rarc -S localhost', shell=True, bufsize=3, stdout=PIPE)
return p
# exec ra -F {argusConfPath}/rarc -S localhost > {outputDir}/realData.txt