Mail file as well as output Mail file as well as output shell shell

Mail file as well as output


Don't pipe the Python script to mail instead redirect the output to a temporary file and then cat that temporary file piping it to the mail command.

For instance:

python script.py > temp-file.out< temp-file.out mail -s "subject" -a filename.txt example@gmail.com