0

I have two shell scripts. One is for creating some logs (abc.sh) in one directory and another script (xyz.sh) is for sending email and moving those logs into different directory. Both script I am calling as below.

cmd="abc.sh"
    try:
        subprocess.call(cmd,shell=True)
    except OSError:
        print "Failed to run this option."
print 'Enter your email-id:'
cmd = "xyz.sh"
    try:
        subprocess.call(cmd,shell=True)
    except OSError:
        print "Failed to run this option

My question is, if someone else running the same python code at the same time they will not get the email with their respective logs for what they have executed the script. Because when someone is entering the email id, 2nd script (xyz.sh) sends mail and delete the logs. So could you please let me know how can we get rid of this situation from python code.

abhiN
  • 15
  • 4
  • This is a problem of concurrent access. There are multiple possible solutions like locking or some other intuitive ways. Here is a good answer http://stackoverflow.com/questions/2301458/python-multiple-threads-accessing-same-file – wolfsgang Jun 16 '16 at 15:22
  • @wolfsgang is it possible you to provide a solution. Multiprocessing is not working is my condition as my python version is 2.7 – abhiN Jun 17 '16 at 05:22

0 Answers0