My subprocess command is not working with quotes.
tail = subprocess.Popen('tail -f -n 1 /mnt/syslog/**/*.log | egrep -v \'^$|mnt\'',\
shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
When I execute python file.py I get a empty line:
# python main.py
^CTraceback (most recent call last):
File "main.py", line 18, in <module>
main()
File "main.py", line 12, in main
line = tail.stdout.readline()
KeyboardInterrupt
It works fine in bash as you can see:
# tail -f -n 1 /mnt/syslog/**/*.log | egrep -v '^$|mnt'
Sep 9 22:44:07 x.x.x.x : %LINK-3-UPDOWN: Interface GigabitEthernet1/0/19, changed state to down
Sep 9 18:32:56 x.x.x.x : %LINK-5-CHANGED: Interface GigabitEthernet1/0/24, changed state to administratively down
What is wrong?