Gentoo Archives: gentoo-server

From: RijilV <rijilv@×××××.com>
To: gentoo-server@l.g.o
Subject: Re: [gentoo-server] Scripting fun
Date: Tue, 10 Jun 2008 03:21:53
Message-Id: 41195fb10806092021i545b7c88t33b46143cdcc5f16@mail.gmail.com
In Reply to: [gentoo-server] Scripting fun by JD Gray
1 echo "$CHECK_RESULT" | /bin/mail -s "$HOSTNAME glsa-check" root@×××××××.com
2
3 FWIW $HOSTNAME should be present in the standard environmnet, makes
4 the script a bit more protable if you use it. Also, is there a reason
5 you're running the command twice? Moreover, if you set it up as a
6 cronjob you could just let cron take care of emailing you if there is
7 any output, and suspress the output if glsa-check doesn't print
8 anything..
9
10 .r'
11
12
13 2008/6/9 JD Gray <kahdgarxi@×××××.com>:
14 > I'm running the below script on my gentoo servers to email me whenever
15 > there are GLSA's affecting me. It works like a charm, but I have one
16 > beef with it. Newlines are not preserved, so I get a lovely Wall Of
17 > Text (tm) when ever it sends me the GLSA. I'm guessing this is because
18 > of the way bash handles variables. Anyone have any insight on how to
19 > correct this?
20 >
21 > #!/bin/bash
22 >
23 > /usr/bin/glsa-check -t all &> /dev/null
24 > CHECK_RESULT="`/usr/bin/glsa-check -t all 2>&1`"
25 >
26 > if [ "$CHECK_RESULT" != "" ]; then
27 > echo $CHECK_RESULT | /bin/mail -s "Frog glsa-check" kahdgarxi@×××××.com;
28 > fi
29 >
30 > Thanks in advance
31 >
32 > -JD
33 > --
34 > gentoo-server@l.g.o mailing list
35 >
36 >
37 --
38 gentoo-server@l.g.o mailing list