Find the answer to your Linux question:
Results 1 to 3 of 3
Is it possible to create a shell script that will run a shell command and email the results?...
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    2

    shell command redirect to e-mail

    Is it possible to create a shell script that will run a shell command and email the results?

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    616
    Code:
    #!/bin/sh
    BODY=`cat message.txt`
    BODY2="ls -la /root"
    BODY3=""
    BODY4=""
    EMAIL=blah@blah.com
    
    if [ -n "${BODY}" ]; then
      (
      echo "Subject: omg";
      echo "To: $EMAIL";
      echo "From: Count Chocula <count.chocula@joke.com>";
      echo;
      echo "$BODY"
      echo "$BODY2"
      echo "$BODY3"
      echo "$BODY4"
      ) | /usr/lib/sendmail -f daCount $EMAIL
    fi
    linux user # 503963

  3. #3
    Just Joined!
    Join Date
    Apr 2010
    Posts
    2
    Works perfectly! Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...