manages spaces in mount point names

This commit is contained in:
Nicolas LLOBERA 2017-03-20 23:19:19 +01:00
parent a879c6d95f
commit 3aa15d98a9
1 changed files with 3 additions and 1 deletions

View File

@ -4,7 +4,9 @@ $Config = new Config();
$datas = array();
if (!(exec('/bin/df -T -P | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df)))
# if there are more than 7 awk's colums it means the mount point name contains spaces
# so consider the first colums as a unique colum and the last 6 as real colums
if (!(exec('/bin/df -T -P | tail -n +2 | awk \'{ if (NF > 7) { for (i=1; i<NF-6; i++) { printf $i" "; } for (i=NF-6; i<NF; i++) { printf $i","; print $NF; } } else { print $1","$2","$3","$4","$5","$6","$7; } }\'', $df)))
{
$datas[] = array(
'total' => 'N.A',