From fb4487bfdc2d7a196665605c9808565b7635537d Mon Sep 17 00:00:00 2001 From: "Steve L. Nyemba" Date: Fri, 3 Feb 2017 08:25:23 -0600 Subject: [PATCH] addressing limitations with xargs, find in terms of output --- src/monitor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/monitor.py b/src/monitor.py index fa45dfa..8aa41bc 100755 --- a/src/monitor.py +++ b/src/monitor.py @@ -240,7 +240,7 @@ class FileWatch(Analysis): else : # # Size provided in bytes we are converting into MB - size = float(x[0]) / 1000000 + size = float(x[0].replace('B','')) / 1000000 month = months.index(x[1]) + 1 day = int(x[2]) age = -1 @@ -251,6 +251,7 @@ class FileWatch(Analysis): year = int(x[4]) else: year = datetime.datetime.today().year + print [year,month,day,x[4]] file_date = datetime.datetime(year,month,day,int(hour),int(minute)) size = round(size,2) #file_date = datetime.datetime(year,month,day,hour,minute) @@ -259,7 +260,7 @@ class FileWatch(Analysis): return None def evaluate(self,path): - cmd = "find :path|xargs ls -lh |awk '{print $5,$6,$7,$8,$9}'".replace(":path",path) + cmd = "find :path -print0|xargs -0 ls -ls |awk '{print $6,$7,$8,$9,$10}'".replace(":path",path) print cmd handler = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE) ostream = handler.communicate()[0].split('\n')