mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Linux

Reply
 
Thread Tools
Old 2015-07-16, 18:19   #1
pepi37
 
pepi37's Avatar
 
Dec 2011
After milion nines:)

58E16 Posts
Default Mail from command line

I would like to write small script that will check "results.txt" every 30 minutes and if found "!", mean PRP or prime is found to send me a mail.
Does some have to point me from where to start, or maybe have done script?
Thanks!
pepi37 is online now   Reply With Quote
Old 2015-07-16, 18:33   #2
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

32·701 Posts
Default

Quote:
Originally Posted by pepi37 View Post
I would like to write small script that will check "results.txt" every 30 minutes and if found "!", mean PRP or prime is found to send me a mail.
Does some have to point me from where to start, or maybe have done script?
Thanks!
If you used PRPNet, it has the ability to send you and e-mail when a prime is found...
rogue is offline   Reply With Quote
Old 2015-07-16, 18:44   #3
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

225508 Posts
Default

Quote:
Originally Posted by pepi37 View Post
Does some have to point me from where to start, or maybe have done script?
If you're working with Perl, use Net::SMTP.

Otherwise, "man sendmail".
chalsall is offline   Reply With Quote
Old 2015-07-16, 20:57   #4
pepi37
 
pepi37's Avatar
 
Dec 2011
After milion nines:)

2×32×79 Posts
Default

Quote:
Originally Posted by rogue View Post
If you used PRPNet, it has the ability to send you and e-mail when a prime is found...
I know about that feature, even thinking to install prpnet server to only use that ... will see what will be simplest solution
pepi37 is online now   Reply With Quote
Old 2015-07-16, 22:06   #5
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3×29×83 Posts
Default

I have a small Python script which makes use of Python's builtin smtp module.

Code:
#! /usr/bin/env python3

host ='smtp.gmail.com'
port = 587
mode = 'tls'
acc = '<sthg>@gmail.com'
pw = ''

def email(*args): # HTML, attachments, cc?
     '''(Subject, Message) or (Recipient, Subject, Message)'''
     if len(args) == 2:
          send_email(acc, acc, args[0], args[1], host, port, True, acc, pw)
     elif len(args) == 3:
          send_email(args[0], acc, args[1], args[2], host, port, True, acc, pw)
     else:
          raise ValueError("email() expects two or three arguments")

import smtplib
from email.utils import formatdate
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

def send_email(to, frm, sbjct, txt, host, port, tls=True, acct=None, pswd=None):
     """To, From, Subject, Body, Server, Port, Account, Password"""
     msg = MIMEMultipart()

     if isinstance(to, list):
          to = ', '.join(to)
     msg['To'] = to
     msg['Subject'] = sbjct
     msg['From'] = frm
     msg['Date'] = formatdate(localtime=True)

     msg.attach(MIMEText(txt))

     server = smtplib.SMTP(host, port)
     if tls:
          server.starttls()
     if acct or pswd:
          server.login(acct, pswd)
     server.send_message(msg)

if __name__ == '__main__':
     from sys import argv
     email(*argv[1:])
Put that ^ into a file called "email.py", modify the account details to whatever you need, `chmod +x email.py` and then via bash you can `./email.py "this is the subject" "this is the message"` or `./email.py "recipient@email.com" "this is the subject" "this is the message"`
Dubslow is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows command line mu5tan6 Software 14 2015-03-20 17:21
Run Benchmark Test using Command Line Only? Gabe Brown Information & Answers 3 2009-12-12 14:01
command line switch wongnog Information & Answers 1 2008-07-20 11:29
NewPGen from the command line monst Software 19 2008-01-31 07:07
MultiSieve from the command line (on Windows) monst Software 7 2007-12-18 02:37

All times are UTC. The time now is 08:36.

Fri May 14 08:36:23 UTC 2021 up 36 days, 3:17, 0 users, load averages: 2.45, 2.58, 2.37

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.