[Tutor] Multiple lines with the command line

Tom Tucker tktucker at gmail.com
Tue Apr 17 00:03:12 CEST 2007


Sorry, you mentioned you wanted to use the Unix mail program.

Is your information static? If yes, how bout this.
cmd = "mail -s 'my subject' user at domain.com <user at domain.com> <
/path/to/static_message"
os.system(cmd)

Similar approach could be to capture the users message body as command line
arguments, save them to a file, and then include them in the execution. Not
very sexy, but it will work.


example
##############
~>/tmp/mail_wrapper.py  this is the body of my message
['this', 'is', 'the', 'body', 'of', 'my', 'message']


#!/usr/bin/env python
import sys
message = sys.argv[1:]

# save message variable to a file
# execute mail command < file




On 4/16/07, Tom Tucker < tktucker at gmail.com> wrote:
>
> Have you tried the "email" module?
>
> http://docs.python.org/lib/module-email.html
>
>
>
> On 4/16/07, Kharbush, Alex [ITCSV] <alexf4 at iastate.edu> wrote:
>
> >
> > I want to use the UNIX Mail program with python
> >
> > I need multiple entries with the os.system(cmd)line
> >
> > I will need something like this
> >
> > #output to unix
> >
> > Mail Alexf4 at iastate.edu -f alexf4 at gmail.com
> > Subject : hello alex
> >
> > #message part
> > how is it going
> >
> > #the end of mail
> > .
> >
> > When I write os.system("Mail Alexf4 at gmail.com") my program will send
> > email to where i want it to go
> >
> > MY PROBLEM is that i need to enter multiple lines of input into unix.
> > os.system() takes only one argument
> >
> > thanks for the time
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070416/840b884b/attachment.htm 


More information about the Tutor mailing list