LDP/LDP/guide/docbook/abs-guide/self-mailer.sh

32 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2002-04-01 16:05:47 +00:00
#!/bin/sh
# self-mailer.sh: Self-mailing script
2002-09-30 15:56:52 +00:00
adr=${1:-`whoami`} # Default to current user, if not specified.
# Typing 'self-mailer.sh wiseguy@superdupergenius.com'
#+ sends this script to that addressee.
# Just 'self-mailer.sh' (no argument) sends the script
#+ to the person invoking it, for example, bozo@localhost.localdomain.
#
# For more on the ${parameter:-default} construct,
#+ see the "Parameter Substitution" section
#+ of the "Variables Revisited" chapter.
2002-04-01 16:05:47 +00:00
2002-09-30 15:56:52 +00:00
# ============================================================================
cat $0 | mail -s "Script \"`basename $0`\" has mailed itself to you." "$adr"
# ============================================================================
2002-04-01 16:05:47 +00:00
# --------------------------------------------
# Greetings from the self-mailing script.
# A mischievous person has run this script,
#+ which has caused it to mail itself to you.
# Apparently, some people have nothing better
#+ to do with their time.
# --------------------------------------------
2002-09-30 15:56:52 +00:00
echo "At `date`, script \"`basename $0`\" mailed to "$adr"."
2002-04-01 16:05:47 +00:00
exit 0
2008-05-09 18:58:34 +00:00
# Note that the "mailx" command (in "send" mode) may be substituted
#+ for "mail" ... but with somewhat different options.