Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 If changes have been made, add a subject line ("Changes have been made") and attach a file ( If no changes have been made, add a different subject line ("no changes has been made").

if [ ! -f "$/suid.old" ]
   find / -perm -4000 -o -perm -2000 > ol.list
   find / -perm -4000 -o -perm -2000 > new.suid
   diff suid.old   >
share|improve this question

migrated from Feb 9 '10 at 9:44

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

to mail a file, one way is to use uuencode

uuencode myfile myfile | mailx -s "subject"
share|improve this answer
hello, do i have to specify myfile myfile twice. – su Feb 9 '10 at 2:28
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

You must log in to answer this question.