I want to use Windows' command net statistics server and use extract date from it which is of pattern : (\d+-\d+-\d+ \d+:\d+:\d+)
def sysCmd(string):
try:
res = subprocess.Popen(string)
return res
except:
return "NULL - Command Error"
loginTime = sysCmd ("net statistics server ") # windows command
loginRex = "(\d+-\d+-\d+ \d+:\d+:\d+)"
loginMatch = re.search(loginRex, str(loginTime))
print (loginMatch.group(0))
I get the error : AttributeError: 'NoneType' object has no attribute 'group'
The regular expression seem to work perfectly well in regex test harnesses for the output this windows command gives. Here it doesn't fail still after so much hit-and-trial.
What am I doing wrong?
p.s. I'm using Python 3