← Back to team overview

sslug-teknik team mailing list archive

Re: Sende mail fra et bash script

 

Kristian Vilmann wrote:

Det er lidt vigtigt. Men den kan nok sende mail alligevel. Så længe du bruger din udbyder SMTP-relay går det nok.

(/user/w3c) #host smtp.mail.dk
smtp.mail.dk has address 193.162.153.3
smtp.mail.dk has address 193.162.153.4
smtp.mail.dk has address 193.162.153.2
tir nov 05 00:01:31 (hcs)@(tux1700)on(pts/5):


OK. DNS virker.

relayhost = [193.162.153.3]
relayhost = [193.162.153.4]
relayhost = [193.162.153.2]
relayhost = smtp.mail.dk

jeg tror kun du kan sætte variablen en gang.

done

hvorfor bliver du ved man at skrive "done" ?


echo "test mail" | mail -s "dette er dit subject" hcstudt@xxxxxxxxxxxxxx
done

/var/log/maillog
----------------------------
Nov 5 00:12:12 tux1700 sendmail[1613]: My unqualified host name (tux1700) unknown; sleeping for retry

Nov 5 00:13:12 tux1700 sendmail[1613]: unable to qualify my own domain name (tux1700) -- using short name

Din MTA starter ikke.

Hvordan er du forbundet til Nettet?
Firewall?
ADSL?
Modem?

Hvad er din IP-adresse?

mail.dk - det er TDC, ikke?

Af uransagelige årsager er der ikke reverse-DNS på deres adresser, medmindre man beder om det.

Nov 5 00:13:16 tux1700 sendmail[1613]: gA4NDC7p001613: from=hcs, size=68, class=0, nrcpts=1, msgid=<200211042313.gA4NDC7p001613@tux1700>, relay=hcs@localhost

Nov 5 00:13:20 tux1700 sendmail[1613]: gA4NDC7p001613: to=hcstudt@xxxxxxxxxxxxxx, ctladdr=hcs (500/500), delay=00:00:08, xdelay=00:00:04, mailer=relay, pri=30058, relay=localhost.localdomain. [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by localhost.localdomain.

Før du fortsætter må du lige hitte ud af hvilken MTA du bruger.
Postfix eller sendmail.

Det er postfix-filen du retter i, men jeg vil vædde på at det er sendmail der skriver disse loglinier.

kan du se hvad jeg kører ?
hvad hedder programmet/daemonen ?

/etc) #ps ax
  PID TTY      STAT   TIME COMMAND
    1 ?        S      0:22 init
    2 ?        SW     0:10 [keventd]
    3 ?        SW     0:15 [kapmd]
    4 ?        SWN   17:17 [ksoftirqd_CPU0]
    5 ?        SW    28:20 [kswapd]
    6 ?        SW     0:33 [bdflush]
    7 ?        SW     0:15 [kupdated]
    8 ?        SW     0:00 [mdrecoveryd]
   12 ?        SW     3:03 [kjournald]
   63 ?        SW     0:00 [khubd]
  157 ?        SW     0:00 [kjournald]
  158 ?        SW     5:02 [kjournald]
  503 ?        S      0:03 syslogd -m 0
  507 ?        S      0:00 klogd -x
  516 ?        S      0:00 portmap
  535 ?        S      0:00 rpc.statd
  605 ?        SW     0:51 [rpciod]
  606 ?        SW     0:00 [lockd]
618 ? S 0:00 /usr/sbin/apmd -p 10 -w 5 -W -P /etc/sysconfig/apm-scripts/apm
  657 ?        S      0:00 /usr/sbin/sshd
671 ? S 0:00 xinetd -stayalive -reuse -pidfile /var/run/xinetd.pid
  686 ?        S      0:00 lpd Waiting
  727 ?        S      1:19 gpm -t ps/2 -m /dev/mouse
  736 ?        S      0:15 crond
  769 ?        S      0:07 xfs -droppriv -daemon
  787 ?        S      0:04 /usr/sbin/atd
  798 ?        S      0:05 rhnsd --interval 120
  805 ?        S      0:00 login -- root
  806 ?        S      0:00 login -- root
  807 ?        S      0:00 login -- root
  808 tty5     S      0:00 /sbin/mingetty tty5
  809 tty6     S      0:00 /sbin/mingetty tty6
  810 ?        S      0:00 /usr/bin/gdm-binary -nodaemon
  846 ?        S      0:00 /usr/bin/gdm-binary -nodaemon
  847 ?        S<   100:48 /usr/X11R6/bin/X :0 -auth /var/gdm/:0.Xauth
  918 tty2     S      0:00 -bash
  994 ?        S      0:00 login -- root
  996 ?        SW     8:44 [kjournald]
 1000 tty3     S      0:00 -bash
 1053 tty3     S      0:13 /usr/bin/mc -P
 1054 ?        S      0:00 cons.saver /dev/tty3
 1055 pts/0    S      0:00 bash -rcfile .bashrc
 1188 tty4     S      0:00 -bash
 1334 tty2     S      0:01 /usr/bin/mc -P
 1335 ?        S      0:00 cons.saver /dev/tty2
 1336 pts/1    S      0:00 bash -rcfile .bashrc
 1477 tty1     S      0:00 -bash
 1592 ?        S      0:00 /bin/sh /usr/bin/startkde
 1659 ?        S      0:08 /usr/bin/ssh-agent /etc/X11/xinit/Xclients
 1714 ?        S      0:02 kdeinit: Running...
 1717 ?        S      0:05 kdeinit: dcopserver --nosid
 1720 ?        S      0:00 kdeinit: klauncher
 1722 ?        S      7:20 kdeinit: kded
1732 ? S 15:36 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
 1738 ?        S      0:21 kdeinit: knotify
 1739 ?        S      0:39 kwrapper ksmserver --restore
 1741 ?        S      0:02 kdeinit: ksmserver --restore
1742 ? S 2:38 kdeinit: kwin -session 117f000001000103351159000000012960000
 1743 ?        S      4:34 /usr/bin/gftp-gtk
 1746 ?        S      0:12 usermount
 1748 ?        S      7:42 kdeinit: kdesktop
 1798 ?        S     12:04 kdeinit: kicker
 1802 ?        S      6:18 kdeinit: klipper -icon klipper -miniicon klipper
 1804 ?        S      0:02 kdeinit: kwrited
1805 ? S 7:58 kdeinit: konsole -session 117f00000100010335116010000001296000 1806 ? S 20:29 kdeinit: konsole -session 117f00000100010335118190000001296000 1807 ? S 5:21 kdeinit: konsole -session 117f00000100010337238900000001296011 1814 ? S 15:14 kdeinit: konqueror -session 117f000001000103463314500000010210 1818 ? R 2166:32 kdf -session 11c0a86e01000103496183500000010610024 1819 ? R 529:26 kdf -session 11c0a86e01000103496298800000010610025
 1823 pts/4    S      0:00 /bin/bash
 1824 pts/3    S      0:00 /bin/bash
 1825 pts/5    S      0:00 /bin/bash
 1833 pts/6    S      0:00 /bin/bash
 1837 pts/21   S      0:01 /bin/bash
 1841 pts/13   S      0:00 /bin/bash
 1847 pts/7    S      0:00 /bin/bash
 1854 pts/22   S      0:00 /bin/bash
 1861 pts/14   S      0:00 /bin/bash
 1867 pts/8    S      0:00 /bin/bash
 1879 pts/15   S      0:00 /bin/bash
 1887 pts/9    S      0:00 /bin/bash
 1897 pts/23   S      0:00 /bin/bash
 1907 pts/16   S      0:00 /bin/bash
1916 ? S 0:03 kalarmd -session 117f000001000103451275700000010980003
 1924 pts/10   S      0:00 /bin/bash
 1937 pts/24   S      0:00 /bin/bash
 1947 pts/17   S      0:00 /bin/bash
 1966 pts/11   S      0:00 /bin/bash
 1979 pts/26   S      0:00 /bin/bash
 1994 pts/18   S      0:00 /bin/bash
 2022 pts/27   S      0:00 /bin/bash
 2035 pts/19   S      0:00 /bin/bash
 2050 pts/12   S      0:00 /bin/bash
 2068 pts/28   S      0:00 /bin/bash
 2086 pts/20   S      0:00 /bin/bash
 2103 pts/25   S      0:00 /bin/bash
 2120 pts/29   S      0:00 /bin/bash
 3017 pts/4    S      0:00 su -
 3020 pts/4    S      0:00 -bash
 3073 pts/6    S      0:00 su -
 3076 pts/6    S      0:00 -bash
 3127 pts/7    S      0:00 su -
 3130 pts/7    S      0:00 -bash
 3181 pts/8    S      0:00 su -
 3184 pts/8    S      0:00 -bash
 3235 pts/9    S      0:00 su -
 3238 pts/9    S      0:00 -bash
 3291 pts/10   S      0:00 su -
 3294 pts/10   S      0:00 -bash
 3345 pts/11   S      0:00 su -
 3348 pts/11   S      0:00 -bash
 3399 pts/12   S      0:00 su -
 3402 pts/12   S      0:00 -bash
 3453 pts/25   S      0:00 su -
 3456 pts/25   S      0:00 -bash
31367 ?        S      0:19 /usr/bin/redhat-config-services
31368 ?        S      0:00 /usr/sbin/userhelper -w redhat-config-services
31371 ? S 0:00 /bin/sh /usr/share/redhat-config-services/redhat-config-servic 31372 ? S 0:24 /usr/bin/python /usr/share/redhat-config-services/serviceconf.
31374 ?        S      0:07 /usr/libexec/gconfd-2 7
12704 ?        S     65:30 /usr/lib/mozilla-1.0.1/mozilla-bin
20436 ?        Z      0:00 [pluginserver <defunct>]
20439 ?        Z      0:00 [pluginserver <defunct>]
20444 ?        Z      0:00 [pluginserver <defunct>]
20447 ?        Z      0:00 [pluginserver <defunct>]
20448 ?        Z      0:00 [pluginserver <defunct>]
20453 ?        Z      0:00 [pluginserver <defunct>]
20690 ?        Z      0:00 [pluginserver <defunct>]
 3141 ?        Z      0:00 [pluginserver <defunct>]
 3144 ?        Z      0:00 [pluginserver <defunct>]
 3147 ?        Z      0:00 [pluginserver <defunct>]
 3152 ?        Z      0:00 [pluginserver <defunct>]
 3416 ?        Z      0:01 [pluginserver <defunct>]
10658 ?        Z      0:00 [pluginserver <defunct>]
18231 ?        Z      0:00 [mozilla-bin <defunct>]
28604 ?        S      0:07 kppp -icon kppp -miniicon kppp
28605 ? S 0:00 /usr/sbin/userhelper -w kppp -icon kppp -miniicon kppp
28608 ?        S      4:24 kppp -icon kppp -miniicon kppp
28609 ?        S      0:00 kppp -icon kppp -miniicon kppp
28611 ?        S      0:00 kdeinit: Running...
28614 ?        S      0:00 kdeinit: dcopserver --nosid --suicide
28617 ?        S      0:00 kdeinit: klauncher
28619 ?        S      1:33 kdeinit: kded
28625 ttyS0 S 0:00 pppd 57600 -detach crtscts defaultroute usepeerdns user 120050
24817 ?        S      0:00 kdeinit: kcookiejar
24922 ?        S      0:02 /usr/bin/kdesud
11186 ?        Z      0:00 [pluginserver <defunct>]
 2012 ?        Z      0:00 [pluginserver <defunct>]
16885 ?        S      6:12 java_vm
 9942 ?        SW     0:08 [kjournald]
10177 ?        S      0:00 rpc.rquotad
10181 ?        SW     0:00 [nfsd]
10182 ?        SW     0:00 [nfsd]
10183 ?        SW     0:00 [nfsd]
10184 ?        SW     0:00 [nfsd]
10185 ?        SW     0:00 [nfsd]
10186 ?        SW     0:00 [nfsd]
10187 ?        SW     0:00 [nfsd]
10188 ?        SW     0:00 [nfsd]
10194 ?        S      0:00 rpc.mountd
27259 ?        Z      0:00 [pluginserver <defunct>]
27726 ?        Z      0:00 [pluginserver <defunct>]
23556 ?        Z      0:00 [pluginserver <defunct>]
 4999 ?        Z      0:00 [pluginserver <defunct>]
 5151 ?        Z      0:00 [pluginserver <defunct>]
15783 pts/19   S      0:00 /bin/bash
15784 pts/19   S      0:13 tee w900.log
 4555 ?        S      0:00 CROND
 4556 ?        S      0:00 /bin/bash /usr/bin/run-parts /etc/cron.daily
 7643 ?        SN     0:00 /bin/sh /etc/cron.daily/slocate.cron
7644 ? S 0:00 awk -v progname=/etc/cron.daily/slocate.cron progname {????? 7646 ? RN 0:45 /usr/bin/updatedb -f NFS,SMBFS,NCPFS,PROC,DEVPTS -e /tmp,/var/
12744 pts/19   S      0:00 /bin/bash
4965 pts/19 S 2:21 /bin/bash /usr/local/bin/hcs/w3c-site-count-2.sh alle^dk^domæn 13831 pts/9 S 0:00 vim w3c-site-count-2-01.awk w3c-site-count-2-02.awk w3c-site-c
29048 pts/11   S      0:00 /usr/bin/mc -P
29098 pts/30   S      0:00 bash -rcfile .bashrc
29549 ?        Z      0:00 [pluginserver <defunct>]
29739 ?        Z      0:00 [pluginserver <defunct>]
7795 pts/3 S 0:00 /bin/bash /usr/local/bin/hcs/w3c-validate-pending-1.sh
 7796 pts/3    S      0:00 tee w3c-validate-pending-1-541.log
28872 pts/26 S 0:00 /bin/bash /usr/local/bin/hcs/w3c-validate-pending-1.sh
28873 pts/26   S      0:00 tee w3c-validate-pending-1-541.log
3601 pts/25 S 0:00 vim /etc/postfix/access /etc/postfix/aliases /etc/postfix/alia
13656 ?        Z      0:00 [pluginserver <defunct>]
14913 ?        Z      0:00 [pluginserver <defunct>]
31643 ?        Z      0:00 [pluginserver <defunct>]
31981 ?        Z      0:00 [pluginserver <defunct>]
32021 ?        Z      0:00 [pluginserver <defunct>]
1488 pts/29 S 0:00 /bin/bash /usr/local/bin/hcs/www-domains-crawl-1.sh save-70.ls
 1489 pts/29   S      0:00 tee www-domains-crawl-1-670.log
23863 pts/29 S 0:00 /bin/bash /usr/local/bin/hcs/www-crawl-grep-1.sh -q 100 www.in 23864 pts/29 S 0:00 tee www-domains-crawl-1/www-domains-crawl-1-000000001-a-100-cr 13473 pts/28 S 0:00 /bin/bash /usr/local/bin/hcs/www-domains-crawl-1.sh save-69.ls
13474 pts/28   S      0:00 tee www-domains-crawl-1-669.log
11195 pts/28 S 0:00 /bin/bash /usr/local/bin/hcs/www-crawl-grep-1.sh -q 100 www.sf 11196 pts/28 S 0:00 tee www-domains-crawl-1/www-domains-crawl-1-000000001-a-100-cr 17775 pts/29 S 0:31 /bin/bash /usr/local/bin/hcs/www-crawl-1.sh -q 103 www-crawl-g
17776 pts/29   S      0:00 tee www-crawl-1-103.log
4790 pts/27 S 0:00 /bin/bash /usr/local/bin/hcs/www-domains-crawl-1.sh save-62.ls
 4791 pts/27   S      0:00 tee www-domains-crawl-1-662.log
16829 pts/3 S 0:30 /bin/bash /usr/local/bin/hcs/w3c-validate-1.sh -q --update-dat
16830 pts/3    S      0:00 tee w3c-validate-1-990-validate.log
28551 ?        Z      0:00 [pluginserver <defunct>]
29119 ?        Z      0:00 [pluginserver <defunct>]
29361 ?        Z      0:00 [pluginserver <defunct>]
19658 pts/28 S 0:18 /bin/bash /usr/local/bin/hcs/www-crawl-1.sh -q 103 www-crawl-g
19659 pts/28   S      0:00 tee www-crawl-1-103.log
19881 pts/27 S 0:00 /bin/bash /usr/local/bin/hcs/www-crawl-grep-1.sh -q 100 www.da 19882 pts/27 S 0:00 tee www-domains-crawl-1/www-domains-crawl-1-000000001-a-100-cr
19332 ?        Z      0:00 [pluginserver <defunct>]
32461 pts/27 S 0:10 /bin/bash /usr/local/bin/hcs/www-crawl-1.sh -q 103 www-crawl-g
32462 pts/27   S      0:00 tee www-crawl-1-103.log
 1431 pts/10   S      0:00 vim /var/log/maillog
20423 pts/17 S 0:00 /bin/bash /usr/local/bin/hcs/w3c-validate-pending-1.sh
20424 pts/17   S      0:00 tee w3c-validate-pending-1-541.log
23251 pts/17 S 0:07 /bin/bash /usr/local/bin/hcs/w3c-validate-1.sh -q --update-dat
23252 pts/17   S      0:00 tee w3c-validate-1-990-validate.log
22942 pts/26 S 0:06 /bin/bash /usr/local/bin/hcs/w3c-validate-1.sh -q --update-dat
22943 pts/26   S      0:00 tee w3c-validate-1-990-validate.log
 7463 pts/5    S      0:00 send-mail -i hcstudt@xxxxxxxxxxxxxx
19217 pts/26 S 0:00 wget --tries=1 --timeout=120 http://validator.w3.org/check?uri 19589 pts/17 S 0:00 wget --tries=1 --timeout=120 http://www.oio.dk/metadata/arbejd 19595 pts/28 S 0:00 /bin/bash /usr/local/bin/hcs/html-get-href-4.sh -q www-crawl-1 19945 pts/28 R 0:00 /bin/bash /usr/local/bin/hcs/html-get-href-5.sh /tmp/html-get-
20156 pts/29   RW     0:00 [www-crawl-1.sh]
20157 pts/29   RW     0:00 [www-crawl-1.sh]
20158 pts/29   S      0:00 cut -c1-30
20159 pts/29   S      0:00 tr [A-Z] [a-z]
20160 pts/29   S      0:00 sed -e s?-*$??
20232 pts/27 S 0:00 /bin/bash /usr/local/bin/hcs/html-get-href-6.sh -q www-crawl-1 20248 pts/27 S 0:00 /bin/bash /usr/local/bin/hcs/html-get-href-6.sh -q www-crawl-1
20249 pts/27   RW     0:00 [dirname]
20274 pts/28 R 0:00 cp -p /tmp/html-get-href-5-19945/html-get-href-5.11 /tmp/html-
20276 pts/3    Z      0:00 [w3c-validate-1. <defunct>]
20319 pts/12   R      0:00 ps ax
Tue Nov 05 00:38:40 (root)@(tux1700)on(pts/12):

--
Hans Christian Studt  : http://hc.studt.dk  mailto:hc@xxxxxxxx
.dk og W3C standarder : http://w3c.studt.dk



Follow ups

References