I have created a script with Python and when executing it, it responds with this message:
Traceback (most recent call last):
File "./pruebaHIDS.py", line 6, in <module>
for filename in listdir("/Escritorio/Scripts"):
OSError: [Errno 2] No such file or directory: '/Escritorio/Scripts'
The problem comes because the directory in particular Desktop / Scripts is not empty.
Does anyone think of a solution or has it happened before?
Edit:
Changing the path to "/ home / ldh / Desktop / Scripts /" as advised in the comments I get a new error:
Traceback (most recent call last):
File "pruebaHIDS.py", line 11, in <module>
print "excepción: " % e
TypeError: not all arguments converted during string formatting
I enclose the code that I am running:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import hashlib
from os import listdir
from os.path import isdir, islink
for filename in listdir("/home/ldh/Escritorio/Scripts/"):
if not isdir(filename) and not islink(filename):
try:
f = open(filename)
except IOError, e:
print "excepción: " % e
else:
data = f.read()
f.close()
print "** %s **" % filename
for algorithm in hashlib.algorithms:
h = getattr(hashlib, algorithm)(data)
print "%s: %s" % (algorithm, h.hexdigest())
print ""