Closed Nicolas01 closed 7 years ago
Hi,
We remove spaces in mount point name because of the Freebox and its "//192.168.x.x/Disque dur" file system name... See #36 and the second last comment (Wohlraj).
If we remove the sed -e 's/[ \t]//'
part, Freebox's users will have an error.
If we keep this sed part, some users (like you) who have only one space between file system and type will have an error...
I'm working on a fix, certainly not very clean but that could work.
Can you try this content of disk.php please ? https://zerobin.net/?b78a33a9d54de136#EIiHPmUyKxYmoQnkzQm9uJsGkFMsqQvGbRHhM2+65ng=
Here's my output of your new command:
/dev/root,ext4,15186900,3040544,11479512,21%,/
devtmpfs,devtmpfs,469688,0,469688,0%,/dev
tmpfs,tmpfs,94804,224,94580,1%,/run
tmpfs,tmpfs,5120,0,5120,0%,/run/lock
tmpfs,tmpfs,189600,0,189600,0%,/run/shm
/dev/mmcblk0p1,vfat,57288,20376,36912,36%,/boot
//192.168.1.2/backups,cifs,480720592,150737700,305563620,34%,/mnt/backups
//192.168.1.254/Disque dur,/mnt/freebox
cifs,/mnt/freebox
239216092,/mnt/freebox
93299912,/mnt/freebox
133741596,/mnt/freebox
42
awk: run time error: not enough arguments passed to printf("42%,")
FILENAME="-" FNR=9 NR=9
Here's my /bin/df -T -P
output:
Sys. fich. Type 1024-blocks Util. Disponible Capacité Monté sur
/dev/root ext4 15186900 3040776 11479280 21% /
devtmpfs devtmpfs 469688 0 469688 0% /dev
tmpfs tmpfs 94804 224 94580 1% /run
tmpfs tmpfs 5120 0 5120 0% /run/lock
tmpfs tmpfs 189600 0 189600 0% /run/shm
/dev/mmcblk0p1 vfat 57288 20376 36912 36% /boot
//192.168.1.2/backups cifs 480720592 150737700 305563620 34% /mnt/backups
//192.168.1.254/Disque dur cifs 239216092 93299912 133741596 42% /mnt/freebox
The output of :
/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; } }'
is :
/dev/root,ext4,15186900,3040812,11479244,21%,/
devtmpfs,devtmpfs,469688,0,469688,0%,/dev
tmpfs,tmpfs,94804,224,94580,1%,/run
tmpfs,tmpfs,5120,0,5120,0%,/run/lock
tmpfs,tmpfs,189600,0,189600,0%,/run/shm
/dev/mmcblk0p1,vfat,57288,20376,36912,36%,/boot
//192.168.1.2/backups,cifs,480720592,150740556,305560764,34%,/mnt/backups
awk: run time error: not enough arguments passed to printf("42%,")
FILENAME="-" FNR=9 NR=9
//192.168.1.254/Disque dur,cifs,239216092,93714532,133326976,42
I tried to reproduce your error:
output='Sys. fich. Type 1024-blocks Util. Disponible Capacité Monté sur
/dev/root ext4 15186900 3040776 11479280 21% /
devtmpfs devtmpfs 469688 0 469688 0% /dev
tmpfs tmpfs 94804 224 94580 1% /run
tmpfs tmpfs 5120 0 5120 0% /run/lock
tmpfs tmpfs 189600 0 189600 0% /run/shm
/dev/mmcblk0p1 vfat 57288 20376 36912 36% /boot
//192.168.1.2/backups cifs 480720592 150737700 305563620 34% /mnt/backups
//192.168.1.254/Disque dur cifs 239216092 93299912 133741596 42% /mnt/freebox'
echo ${output} | 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; } }'
But it worked without error:
/dev/root,ext4,15186900,3040776,11479280,21%,/
devtmpfs,devtmpfs,469688,0,469688,0%,/dev
tmpfs,tmpfs,94804,224,94580,1%,/run
tmpfs,tmpfs,5120,0,5120,0%,/run/lock
tmpfs,tmpfs,189600,0,189600,0%,/run/shm
/dev/mmcblk0p1,vfat,57288,20376,36912,36%,/boot
//192.168.1.2/backups,cifs,480720592,150737700,305563620,34%,/mnt/backups
//192.168.1.254/Disque dur,cifs,239216092,93299912,133741596,42%,/mnt/freebox
Any idea? I use gawk 4.1.4 on bash 4.4.012
/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; } }'
prints:
/dev/root,ext4,15186900,3040752,11479304,21%,/
devtmpfs,devtmpfs,469688,0,469688,0%,/dev
tmpfs,tmpfs,94804,224,94580,1%,/run
tmpfs,tmpfs,5120,0,5120,0%,/run/lock
tmpfs,tmpfs,189600,0,189600,0%,/run/shm
/dev/mmcblk0p1,vfat,57288,20376,36912,36%,/boot
//192.168.1.2/backups,cifs,480720592,150740904,305560416,34%,/mnt/backups
awk: run time error: not enough arguments passed to printf("42%,")
FILENAME="-" FNR=8 NR=8
//192.168.1.254/Disque dur,cifs,239216092,94186336,132855172,42
bash 4.2.37 mawk 1.3.3 raspbian wheezy
I also try on a Jessie VM and same output :/
It's a problem with mawk
which doesn't manage well the percent sign of 42%
in printf
Awesome! It works perfectly! Thanks a lot!
The suppression of spaces in mount point creates a bug in my server.
Here is the result of the command:
/bin/df -T -P
/dev/mmcblk0p1 vfat 65390 2790 62600 5% /boot
As you can see there is a space between the first and the second column. Here is the result of the command:/bin/df -T -P | sed -e 's/[ \t]//'
/dev/mmcblk0p1vfat 65390 2790 62600 5% /boot
As the space has been removed the columns 1 and 2 have merged, which creates the problem. What's the point to remove spaces in mount point names?