0
I am trying to create a shell script that echo's a bunch of commands and have gotten it to send out emails fairly simply.
{
echo $(hostname)
echo ""
echo "Uptime" $(uptime)
echo ""
echo "Who is on the server?" $(who)
echo ""
echo "Recent logs" $(last)
}| mail -s "Homework Report" myemail@gmail.com
The outputs on the emails are all in a single sentence, raw format:
myhostname.com
Uptime 2:27PM up 15:59, 1 users, load averages: 0.44, 0.55, 0.51
Who is on the server? ec2-user pts/0 Dec 17 14:26 (pool-123-45-678-91.state.fios.verizon.net)
Recent logs ec2-user pts/0 Dec 17 14:26 pool-123-45-678-91.state Sun Dec 17 14:26 still logged in pool-123-45-678-91.state Sun Dec 17 05:12 - 05:13 (00:01) pool-123-45-678-91.state Sun Dec 17 02:45 - 05:12 (02:26) ec2-user pts/0 pool-123-45-678-91.state Sat Dec 16 22:28 - 02:16 (03:47) boot time Sat Dec 16 22:28 shutdown time Sat Dec 16 22:27 ec2-user pts/0 pool-123-45-678-91.state Sat Dec 16 21:48 - shutdown (00:38) ec2-user pool-123-45-678-91.state Fri Dec 15 23:45 - 23:45 (00:00) ec2-user pts/0 pool-123-45-678-91.state Fri Dec 15 23:23 - 23:23 (00:00) ec2-user pts/0 pool-123-45-678-91.state Fri Dec 15 23:23 - 23:23 (00:00) boot time Fri Dec 15 23:23 boot time Fri Dec 15 23:21 utx.log begins Fri Dec 15 23:21:59 UTC 2017
What is the best way to format the outputs so that is looks like the outputs on the command lines?
Could you include received message in "raw format"? [Remove
Received:
headers] – AnFi – 2017-12-17T09:00:08.750@AnFi Good morning! I have added the raw format message, let me know if you need anything else. – Lgalan90 – 2017-12-17T14:39:15.170