Skip to content

Instantly share code, notes, and snippets.

@ndmanvar
Last active October 20, 2016 21:58
Show Gist options
  • Save ndmanvar/c130ded50c20d5e7d91d5862a2edbe0a to your computer and use it in GitHub Desktop.
Save ndmanvar/c130ded50c20d5e7d91d5862a2edbe0a to your computer and use it in GitHub Desktop.
import time
import os
write_file = 'C:\Users\Administrator\Downloads\zzz.log'
w_file = open(write_file, 'w')
w_file.write('testing\n')
w_file.close()
while True:
file = 'C:\Users\Administrator\Downloads\somefile1'
if os.path.isfile(file):
# open file and obtain content
f = open(file, 'r')
content = f.read()
if content == "remove file x":
print "x"
elif content == "invoke autoit script x":
print "y"
# close file handle
f.close()
# remove file so this condition doesn't happen again
os.remove(file)
# optional sleep for five seconds
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment