Eu tenho um problema estranho ao enviar um gato ao correio.
Eu tenho um arquivo de texto simples que foi compilado de um script, que é um relatório sobre quais pastas foram copiadas no script. Eu então quero enviar este relatório por e-mail para os administradores do sistema.
O script gera o relatório bem. Quando eu corro
cat /tmp/report.txt
Eu recebo uma saída bem formatada com todas as quebras de linha que eu esperaria.
Copy report. Started on Mon Sep 28 13:37:57 BST 2015
Run in progress?: Yes
3 directories were copied.
Copy started on 2015.09.28 at 13:37:57
Copying /mnt/smb/New folder (10) to /mnt/backup/New folder (10)
Copy completed on 2015.09.28 at 13:37:57
Copy info:
0.01user 0.47system 0:01.83elapsed 26%CPU (0avgtext+0avgdata 2668maxresident)k
0inputs+355896outputs (0major+150minor)pagefaults 0swaps
Copy started on 2015.09.28 at 13:37:59
Copying /mnt/smb/New folder (14) to /mnt/backup/New folder (14)
Copy completed on 2015.09.28 at 13:37:59
Copy info:
0.00user 0.41system 0:01.78elapsed 23%CPU (0avgtext+0avgdata 2620maxresident)k
0inputs+355896outputs (0major+152minor)pagefaults 0swaps
Copy started on 2015.09.28 at 13:38:01
Copying /mnt/smb/New folder (18) to /mnt/backup/New folder (18)
Copy completed on 2015.09.28 at 13:38:01
Copy info:
0.00user 0.28system 0:01.71elapsed 16%CPU (0avgtext+0avgdata 2768maxresident)k
0inputs+355896outputs (0major+151minor)pagefaults 0swaps
No entanto, por algum motivo, quando eu canalizo isso para o correio
cat /tmp/report.txt | mail -s "Copy Report" [email protected]
ou
mail -s "Copy Report" [email protected] < /tmp/report.txt
Este é o email que recebo.
Copy report. Started on Mon Sep 28 13:37:57 BST 2015
Run in progress?: Yes
3 directories were copied.
Copy started on 2015.09.28 at 13:37:57
Copying /mnt/smb/New folder (10) to /mnt/backup/New folder (10) Copy completed on 2015.09.28 at 13:37:57 Copy info:
0.01user 0.47system 0:01.83elapsed 26%CPU (0avgtext+0avgdata 2668maxresident)k
0inputs+355896outputs (0major+150minor)pagefaults 0swaps
Copy started on 2015.09.28 at 13:37:59
Copying /mnt/smb/New folder (14) to /mnt/backup/New folder (14) Copy completed on 2015.09.28 at 13:37:59 Copy info:
0.00user 0.41system 0:01.78elapsed 23%CPU (0avgtext+0avgdata 2620maxresident)k
0inputs+355896outputs (0major+152minor)pagefaults 0swaps
Copy started on 2015.09.28 at 13:38:01
Copying /mnt/smb/New folder (18) to /mnt/backup/New folder (18) Copy completed on 2015.09.28 at 13:38:01 Copy info:
0.00user 0.28system 0:01.71elapsed 16%CPU (0avgtext+0avgdata 2768maxresident)k
0inputs+355896outputs (0major+151minor)pagefaults 0swaps
O que dá? Algumas quebras de linha estão lá, outras não! Eu tentei editar o arquivo em vi e nano e assegurei que as quebras de linha estavam realmente lá. Também os apagou e os fez novamente e a saída de e-mail permanece a mesma.
Usando / usr / bin / mail
Mais informações:
Entreguei o seguinte em um arquivo de texto e fiz o mesmo pipe para o email. Eu coloquei a palavra "Copy" no começo de cada linha.
Copy started on 2015.09.28 at 13:37:57
Copying /mnt/smb/New folder (10) to /mnt/backup/New folder (10)
Copy completed on 2015.09.28 at 13:37:57
Copy info:
Copy 0.01user 0.47system 0:01.83elapsed 26%CPU (0avgtext+0avgdata 2668maxresident)k
Copy 0inputs+355896outputs (0major+150minor)pagefaults 0swaps
Isso é o que recebi no e-mail:
Copy started on 2015.09.28 at 13:37:57
Copying /mnt/smb/New folder (10) to /mnt/backup/New folder (10) Copy completed on 2015.09.28 at 13:37:57 Copy info:
0.01user 0.47system 0:01.83elapsed 26%CPU (0avgtext+0avgdata 2668maxresident)k
0inputs+355896outputs (0major+150minor)pagefaults 0swaps
Em seguida, removi todas as palavras "Copiar". Isso é o que recebi no email.
Started on 2015.09.29 at 09:46:49
Copying /mnt/smb/New folder (10) to /mnt/backup/New folder (10) Completed on 2015.09.29 at 09:46:49
Info:
0.00user 0.46system 0:01.98elapsed 23%CPU (0avgtext+0avgdata 2552maxresident)k
0inputs+355896outputs (0major+149minor)pagefaults 0swaps
Pensei que poderia ser algo relacionado à palavra "Copiar", mas ainda tenho uma linha sem quebra de linha!
Esta é a saída de cat -vet /tmp/report.txt
Copy report. Started on Mon Sep 28 13:37:57 BST 2015$
$
Run in progress?: Yes$
$
$
$
3 directories were copied.$
$
$
Copy started on 2015.09.28 at 13:37:57$
Copying /mnt/smb/New folder (10) to /mnt/backup/New folder (10)$
Copy completed on 2015.09.28 at 13:37:57$
Copy info:$
0.01user 0.47system 0:01.83elapsed 26%CPU (0avgtext+0avgdata 2668maxresident)k$
0inputs+355896outputs (0major+150minor)pagefaults 0swaps$
$
$
Copy started on 2015.09.28 at 13:37:59$
Copying /mnt/smb/New folder (14) to /mnt/backup/New folder (14)$
Copy completed on 2015.09.28 at 13:37:59$
Copy info:$
0.00user 0.41system 0:01.78elapsed 23%CPU (0avgtext+0avgdata 2620maxresident)k$
0inputs+355896outputs (0major+152minor)pagefaults 0swaps$
$
$
Copy started on 2015.09.28 at 13:38:01$
Copying /mnt/smb/New folder (18) to /mnt/backup/New folder (18)$
Copy completed on 2015.09.28 at 13:38:01$
Copy info:$
0.00user 0.28system 0:01.71elapsed 16%CPU (0avgtext+0avgdata 2768maxresident)k$
0inputs+355896outputs (0major+151minor)pagefaults 0swaps$