浏览代码

addressing limitations with xargs, find in terms of output

Steve L. Nyemba 8 年之前
父节点
当前提交
fb4487bfdc
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/monitor.py

+ 3 - 2
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')