Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The following script runs and finds if any new suid has been changed, and redirects the output to a file.

I want to add a mail command in the script, that will send mail to someone@domain.com. If changes have been made, add a subject line ("Changes have been made") and attach a file (changes.new). If no changes have been made, add a different subject line ("no changes has been made").

#!/usr/local/bin/bash
if [ ! -f "$/suid.old" ]
then
   find / -perm -4000 -o -perm -2000 > ol.list
else
   find / -perm -4000 -o -perm -2000 > new.suid
   diff suid.old suid.new   > changes.new
fi
share|improve this question

migrated from stackoverflow.com Feb 9 '10 at 9:44

This question came from our site for professional and enthusiast programmers.

1 Answer 1

to mail a file, one way is to use uuencode

uuencode myfile myfile | mailx -s "subject" recipient@domain.com
share|improve this answer
    
hello, do i have to specify myfile myfile twice. –  su Feb 9 '10 at 2:28
1  
yes. why don't you try it out? type the above command and run it, then try specifying file name once and run it again. –  user31894 Feb 9 '10 at 3:03
    
Hello, Actaully I was hoping to include the mail command inside the script. Plan was to run this script in the cron utility every night, and cron will mail the file if it finds any changes in the file once started. How can i write the mail command inside the script and run it from the cron utility? –  su Feb 9 '10 at 4:11
    
just put the command in the appropriate if/else statement. –  user31894 Feb 9 '10 at 4:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.