Re: [Integrit-users] scripting the e-mail
Brought to you by:
ecashin
From: Ed L C. <ec...@ug...> - 2003-08-02 03:49:00
|
Scott Anderson <sco...@ma...> writes: > I am still having problems with my script for integrit. I am trying to > pipe the output from integrit into a text file. Then if the exit code > for grep is 1 i want grep to send me an email that tells me whats > up...heres how i am trying to do it... > > /usr/local/sbin/integrit -C $config -c | /root/integrit1.txt This is really a shell scripting question. There's a usenet newsgroup specifically dedicated to this kind of thing: comp.unix.shell Right off the bat, though, it looks like you are trying to pipe the output of integrit to a text file. Pipes, though, are for connecting processes. Since the text file isn't a process, you can't use a pipe. You can simply redirect the output into the text file, though. With a bourne-shell flavor of shell (like bash, for instance), you could change the above line to this: /usr/local/sbin/integrit -C $config -c > /root/integrit1.txt 2>&1 > if [ $? = "1" ]; then > (printf "To: $recipient\nSubject: Integrit found a change\n\n"); > /bin/grep changed integrit1.txt | /usr/lib/sendmail -t || > exit 1 elif test $? != "0"; then # send mail about the error > fi -- --Ed L Cashin PGP public key: http://noserose.net/e/pgp/ |