-2
files = []
with open("[...].log", "a+") as posshell:
    for line in files:
        print(line)
        posshell_files.append(line)

I have no clue. It prints nothing. The array is empty. I've tried grabbing every null character and removing them in case it's UTF16 -> open as UTF8, didn't work.

Dylan Moore
  • 443
  • 4
  • 14

2 Answers2

2

You are passing the incorrect second argument to the open call to read the file in this way:

posshell_files = []
with open("posshell.log", "r") as posshell:
    for line in posshell:
        print(line)
        posshell_files.append(line)

According to the Python docs for open, 'r' if the default flag for reading while 'a+' is for reading and writing but you will have to do so in a different manner:

with open("posshell.log","a+") as f:
    f.seek(0)
    print(f.read())
Daniel Corin
  • 1,987
  • 2
  • 15
  • 27
0

Try this

with open('posshell.log') as p:
    content = p.readlines()
    content = [x.strip() for x in content] 
MishaVacic
  • 1,812
  • 8
  • 25
  • 29