I am getting the output of a directory using subprocess like this :-
directory_content = subprocess.getoutput("ssh -i /key.pem ubuntu@IP ls -l --time-style=long-iso /opt/orientdb/databases" | awk -F' ' '{print $6 $8}'")
And i am converting the output to a list of tuples such that i get the directory and the date on which the directory was created.
[('2019-04-25', 'database1'), ('2019-04-26', 'database2') .......]
And i am looping over list and getting the respective directory
for date,db in directory_content:
if (date == '2019-04-25'):
os.remove(db)
but i am getting the error message :-
os.remove(db)
FileNotFoundError: [Errno 2] No such file or directory
I can use some help on how i can delete the directory. Thank you.