I want to run a command in a python file,and then results from that command,to be inside an array so i can insert that array inside a db later.Here's my code:
import sqlite3
import subprocess
assetfinder = subprocess.Popen(["assetfinder -subs-only cysecor.rs | sort -u"], stdout=subprocess.PIPE, shell=True)
assetfinder_out = assetfinder.stdout.read().decode('utf-8')
domains = []
for item in assetfinder_out:
domains.append(assetfinder_out.strip())
print(domains)
conn.commit()
conn.close()
Here is my output:
['autodiscover.cysecor.rs\ncpanel.cysecor.rs\ncpcalendars.cysecor.rs\ncpcontacts.cysecor.rs\ncysecor.rs\nkurs.cysecor.rs\nmail.cysecor.rs\nwebdisk.cysecor.rs\nwebmail.cysecor.rs\nwww.cysecor.rs\nwww.kurs.cysecor.rs', 'autodiscover.cysecor.rs\ncpanel.cysecor.rs\ncpcalendars.cysecor.rs\ncpcontacts.cysecor.rs\ncysecor.rs\nkurs.cysecor.rs\nmail.cysecor.rs\nwebdisk.cysecor.rs\nwebmail.cysecor.rs\nwww.cysecor.rs\nwww.kurs.cysecor.rs', 'autodiscover.cysecor.rs\ncpanel.cysecor.rs\ncpcalendars.cysecor.rs\ncpcontacts.cysecor.rs\ncysecor.rs\nkurs.cysecor.rs\nmail.cysecor.rs\nwebdisk.cysecor.rs\nwebmail.cysecor.rs\nwww.cysecor.rs\nwww.kurs.cysecor.rs', 'autodiscover.cysecor.rs\ncpanel.cysecor.rs\ncpcalendars.cysecor.rs\ncpcontacts.cysecor.rs\ncysecor.rs\nkurs.cysecor.rs\nmail.cysecor.rs\nwebdisk.cysecor.rs\nwebmail.cysecor.rs\nwww.cysecor.rs\nwww.kurs.cysecor.rs', 'autodiscover.cysecor.rs\ncpanel.cysecor.rs\ncpcalendars.cysecor.rs\ncpcontacts.cysecor.rs\ncysecor.rs\nkurs.cysecor.rs\nmail.cysecor.rs\nwebdisk.cysecor.rs\nwebmail.cysecor.rs\nwww.cysecor.rs\nwww.kurs.cysecor.rs'
This cloned like 100 times.I want to get every item not all items in 1 item,and then that one item cloned 100 times.Any fix??
domains = assetfinder_out.strip().split()…?