- Use subprocess.call instead of os.system

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@378 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.x
Cyril Jaquier 2006-09-21 21:20:29 +00:00
parent 2c737f77f1
commit bb6c14bfea
1 changed files with 12 additions and 11 deletions

View File

@ -24,7 +24,8 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
import time, logging, os import time, logging
from subprocess import call
# Gets the instance of the logger. # Gets the instance of the logger.
logSys = logging.getLogger("fail2ban.actions.action") logSys = logging.getLogger("fail2ban.actions.action")
@ -211,13 +212,13 @@ class Action:
@staticmethod @staticmethod
def executeCmd(realCmd): def executeCmd(realCmd):
logSys.debug(realCmd) logSys.debug(realCmd)
retval = os.system(realCmd) try:
#if not retval == 0: retcode = call(realCmd, shell=True)
# logSys.error("'" + cmd + "' returned " + `retval`) if retcode < 0:
# raise Exception("Execution of command '%s' failed" % cmd) logSys.error("%s returned %x" % (realCmd, -retcode))
if retval == 0: else:
return True logSys.debug("%s returned %x" % (realCmd, retcode))
else: return True
logSys.error("%s returned %x" % (realCmd, retval)) except OSError, e:
return False logSys.error("%s failed with %s" % (realCmd, e))
return False