I am trying to e-mail myself a log file using gzip and mailx.
I realise I can write a script that gzips the log, then mails the
zipped file,
then rm the gzip file. However, I am trying do this without physically
creating the zip by "cat" ing the contents of the txt file into
compressed file using the following command,
cat log.txt | gzip | uuencode logfile.txt.gz | mailx -s "Log files
attached" DeL...@gmail.com
However, when I ftp the file to a Windows box, the zip file doesn't
contain a txt file as expected but an Untitled piece of code that
Windows can't view.
How do I force gzip to include a title for the text such as
logfile.txt - as this would then enable me to read the log within my
e-mail??????
> cat log.txt | gzip | uuencode logfile.txt.gz | mailx -s "Log files
> attached" DeL...@gmail.com
That command works just fine. The uuencoded file is attached as
expected and any e-mail program that supports uuencoding can decode
it. For example, with Thunderbird or Mozilla you can save
the .gz attachment which you would gunzip or gzcat to view it.
When I tried to do the same to a gmail account though, all I got
was the uuencoded text - it seems gmail does not support uuencoded
attachments. In that case you could install some mime tools like
"mpack" instead of uuencode.
> How do I force gzip to include a title for the text such as
> logfile.txt - as this would then enable me to read the log within my
> e-mail??????
I don't know of any e-mail program that would display the compressed
text directly. You are sending a gzip file not a text file.
I don't know if Windows can open a gzip file directly either, perhaps
Winzip can open it.
> cat log.txt | gzip | uuencode logfile.txt.gz | mailx -s "Log files
> attached" DeL...@gmail.com
Something else you can try is to actually make a zip file instead of gzip,
in case your Windows software cannot handle .gz attachments
zip - log.txt | uuencode log.zip | mailx ....
(zip is not included with older versions of Solaris, but it is there
for at least Solaris 9 & 10)
and if you get scrambled text on Windows, you can tell zip to
convert the text from Unix to DOS with "zip -l", e.g.
zip -l - log.txt | uuencode log.zip | mailx ....
Or if you have mpack to send it as MIME instead of uuencode:
zip log.zip log.txt
mpack -s "file attached" log.zip DeL...@gmail.com
rm log.zip
(I don't think mpack can take piped input)
Oscar