Python awk command -
import os import sys os.system ('kill "$(ps aux | grep snmp | awk '"{print $2}"' | head -n1)"')
i trying kill process in python, have error line:
awk: line 2: missing } near end of file sh: 1: kill: illegal number
the problem comes awk command, don't know exact syntax. can me please?
thank in advance!
the '
around awk '
terminates python string, end concatenation of 'kill "$(ps aux | grep snmp | awk '
, "{print $2}"
, , ' | head -n1)"'
, trying execute:
$ kill "$(ps aux | grep snmp | awk {print $2} | head -n1)"
where {
parsed shell syntax.
this should work:
os.system('kill "$(ps aux | grep snmp| awk \'{print $2}\' | head -n1)"')
a possibly better approach use pkill:
os.system('pkill snmp')
Comments
Post a Comment