I'm trying to execute a shell command from python. Here's the command :
(flock -n 200 || (echo no; exit 1) && (echo yes; cat /home/user/Desktop/instructions.json; >/home/user/Desktop/instructions.json)) 200>>/home/user/Desktop/instructions.json
I tried os.system() or subprocess.call(); However I always have the same error which is :
/bin/sh: 1: Syntax error: word unexpected
I think the problem is due to parentheses but I'm not sure.
I'm trying to read the file thanks to cat then delete its content IF it's not locked else just echo no and exit.
This command works in shell.