![]() |
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! |
[QUOTE=pepi37;405958]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![/QUOTE] If you used PRPNet, it has the ability to send you and e-mail when a prime is found... |
[QUOTE=pepi37;405958]Does some have to point me from where to start, or maybe have done script?[/QUOTE]
If you're working with Perl, use Net::SMTP. Otherwise, "man sendmail". |
[QUOTE=rogue;405961]If you used PRPNet, it has the ability to send you and e-mail when a prime is found...[/QUOTE]
I know about that feature, even thinking to install prpnet server to only use that ... will see what will be simplest solution |
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:])[/code] 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"` |
| All times are UTC. The time now is 08:28. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.