File: get-email.sh

package info (click to toggle)
dosemu 0.66.7-13
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,672 kB
  • ctags: 7,566
  • sloc: ansic: 60,209; sh: 3,965; asm: 2,219; yacc: 1,980; makefile: 831; perl: 598; lex: 506; awk: 398
file content (59 lines) | stat: -rwxr-xr-x 1,410 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# Writes a (hopefully) valid email address on STDOUT.
#
# Method:
# Look for & use DOSEMUFROM, else
# Look for & use SKIMFROM, else
# Get the LoginID & hostname
# Look for & use pine's 'reply-to', else
# Look for & set hostname from pine's 'user-domain'
# Look for & set hostname from sendmails 'DM'
# Use LoginID@hostname
#
TEMP=/tmp/$0.$$

clean-up() {
    rm -f $TEMP
    exit 0
}

if [ "@$DOSEMUFROM" != "@" ]
then
    echo $DOSEMUFROM
    clean-up
elif [ "@$SKIMFROM" != "@" ]
then
    echo $SKIMFROM
    clean-up
else
    # Do it the hard way!

    # Try to find out who we are. 'whoami' should work, but I don't trust
    # it to be set up right ... 8-). $USER certainly works for BASH.
    MYSELF=`whoami || echo $USER`

    # Assume that 'hostname -f' is well enough supported to be the default 
    # choice. I'm assuming that it is at least standard under Linux ...
    # Otherwise hope that 'uname -n' gives the FQDN instead.
    HOSTNAME=`hostname -f || uname -n`

    # Try and get a reply-to from the ~/.pinerc
    if ( grep "^reply-to" $HOME/.pinerc > $TEMP 2> /dev/null )
    then
	echo `cut -c10- $TEMP`
	clean-up
    fi

    if ( grep "^user-domain" $HOME/.pinerc > $TEMP 2> /dev/null )
    then
	HOSTNAME=`cut -c13- $TEMP`
    fi

    if ( grep "^DM" /etc/sendmail.cf > $TEMP 2> /dev/null )
    then
	HOSTNAME=`cut -c3- $TEMP`
    fi

    echo "$MYSELF@$HOSTNAME"
    clean-up
fi