How would one go about making a script to first edit a newly found file within a specific directory, and then upload it through incron/python? I'm a bit confused as how to specify the filename as a string in the python script.
incrontab -e :
/var/test IN_CREATE /var/pythoncode/code.py
python code:
s = open("confused.txt").read()
s = s.replace("string1", "string2")
f = open("confused.txt", 'w')
f.write(s)
f.close()
Essentially, I am trying to have the incron service find any new file that is found within /var/test
folder , and then execute python code to look for and replace a string within the new file found in /var/test
. However, I am uncertain how to approach the "confused.txt"
filename string, since each file found with the /var/test
will have a dynamic name.