On Monday 04 December 2000 21:42, you wrote:

> > On Monday 04 December 2000 06:35 pm, you wrote:
>
> [...]
>
> > I would like to setup a script that simply sends mail to my
> > [EMAIL PROTECTED] mail account.  Simply running "mail
> > [EMAIL PROTECTED]" wont work since it subsequently wants a
> > "Subject:", ctrl-D to end the message, and a "Cc:".  I assume I need
> > a script to handle this.  I would like to simply send "ip address
> > check" to the subject, nothing in the message body, and nothing in
> > the cc field.  Can anyone help me out here?
>
> I have made a little progress on my own here.  I have read enough to
> know how to send mail to an address without a script except I still
> don't know how to get a message to actually send since the mail program
> requires a "ctrl-d" to end the body.  I want to send an empty body
> since all I am interested in is the mail headers.
>
> I am almost there with this command:
>
> mail -s "ip update message" [EMAIL PROTECTED]
>
> This will produce a message with a subject of "ip update message" and
> add my email to the "To:" field.  It does leave an empty message body
> and doesn't send a "ctrl-d" command to mail which is required to
> sending.  How do I do that?
>
> praedor


I do something similar in python, it extracts the ip address ftom 
ifconfig, then mails it to me at my work address

#!/usr/bin/python

import rfc822, string, sys
import smtplib, os, tempfile
import time

# change this to the "From" address
fromaddr="[EMAIL PROTECTED]"

# change this to the "To" address
toaddr="[EMAIL PROTECTED]"

curr_time=time.asctime(time.localtime(time.time()))
msg="Subject:" + curr_time + "\n" + "current ip data @ " + curr_time +"\n"

ftemp=tempfile.mktemp()
os.system("/sbin/ifconfig ppp0 > "+ftemp)
f=open(ftemp,'r')
txt=f.readlines()

# this line sucks the ip address out from ifconfig
msg=msg+string.splitfields(string.lstrip(txt[1]))[1]
 
server = smtplib.SMTP('localhost')
server.set_debuglevel(1)

server.sendmail(fromaddr,toaddr,msg)

server.quit()
-- 
Alex
(Go easy on me, I'm a COBOL programmer in real life)

Keep in touch with http://mandrakeforum.com: 
Subscribe the "[EMAIL PROTECTED]" mailing list.

Reply via email to