Published - 3 years ago ( Updated - 3 years ago )
I use Python to execute the template of system commands
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from subprocess import Popen, PIPE, STDOUT
command='uname -a'. split()
proc=Popen(command,bufsize=0, stdout=PIPE,stderr=PIPE, universal_newlines=True);
output, error = proc. communicate()
exit_code=proc.poll()
if (exit_code==0):
print(output)
else:
print(error)
No Comment
Post your comment