tag:blogger.com,1999:blog-35838385166968976262024-03-05T17:11:14.523-08:00Scale and Performance of SoftwareAnonymoushttp://www.blogger.com/profile/00325244240791275990noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3583838516696897626.post-33437699211055524842015-01-12T18:13:00.005-08:002015-01-12T18:14:22.778-08:00Using Docker on Mac OS X<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
Installation</h2>
<br />
Docker is the newest iteration of linux containers - self-contained, chroot-like minature VM. Docker is an OSS product, produced by https://www.docker.com/ .<br />
<br />
Installing it on Mac OS X requires installing VirtualBox, Docker and boot2docker. I used Home Brew package manager to install (I had VirtualBox installed already)<br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace;">brew update </span><br />
<span style="font-family: "Courier New",Courier,monospace;">brew install docker</span><br />
<span style="font-family: "Courier New",Courier,monospace;">brew install boot2docker</span><br />
<span style="font-family: "Courier New",Courier,monospace;">boot2docker init</span><br />
<span style="font-family: "Courier New",Courier,monospace;">boot2docker up</span><br />
<br />
The up command returns three environment variables DOCKER_CERT_PATH, DOCKER_TLS_VERIFY and DOCKER_HOST that need to be exported to your environment.<br />
<br />
After this, docker is installed and ready to use.<br />
<br />
Find a list of docker images with the command<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">docker images</span><br />
<br />
Initially there will be no images. When using docker to create a new image, the actual image is downloaded and installed. After that first install, that image will be available for future use.<br />
<br />
<h2 style="text-align: left;">
Creating first Docker Container</h2>
<br />
Let's create a CentOS container.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">docker run --rm -i -t centos /bin/bash</span><br />
<br />
<br />
That's it. All the needed packages will be downloaded and installed<br />
You will be popped into a root prompt of the container - essentially a fully featured CentOS system with its own filesystem, network stack, IP, etc.<br />
<br />
--rm means it will destroyed on exit<br />
-i means interactive (because we are running /bin/bash inside the centos image)<br />
<br />
Compute to heart's content. Exit with Control-D and the container is destroyed.<br />
<br />
<br />
<br />
<h2 style="text-align: left;">
Creating a non-transient docker image</h2>
<br />
<span style="font-family: "Courier New",Courier,monospace;">docker run -i -t centos /bin/bash</span><br />
<br />
Make changes to this container (create files) and exit<br />
<br />
Now, the command "<span style="font-family: "Courier New",Courier,monospace;">docker ps -a</span>" should show a new container.<br />
You can save the state of this container aas a new image using<br />
<span style="font-family: "Courier New",Courier,monospace;">docker commit CONTAINERID NAME</span><br />
after which "docker images" should show the new image listed with NAME. <br />
<br />
<h2 style="text-align: left;">
Dockerfiles</h2>
<br />
Dockerfiles are bootstrap files that can be associated with an image. It can be used to install new packages, mount filesystems, execute commands, etc. Sample docker files are shared by the OSS community on hub.docker.com<br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/00325244240791275990noreply@blogger.com0tag:blogger.com,1999:blog-3583838516696897626.post-78748258980261763202015-01-07T10:58:00.003-08:002015-01-07T10:58:35.305-08:00Using Amazon Simple Storage Services (S3) as cheap, reliable DIY backup solution<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
Using Amazon Simple Storage Services (S3) as a cheap, reliable DIY backup solution</h2>
<br />
<h3 style="text-align: left;">
Background:</h3>
<br />
A non-profit organization's machine had a MySQL failure and part of the database got corrupted. Unfortunately, we did not have a recent backup. We restored the last available backup.<br />
<br />
However, this was a wake up call to implement a regular backup plan for the organization's data:<br />
A. MySQL dumps - approximately 500Mb <br />
B. Regular disk files - approximately 50+Gb<br />
<br />
Backup frequency could be a full backup once per week and an incremental backup once per day. <br />
<br />
<br />
<h3 style="text-align: left;">
Investigating available options:</h3>
<br />
Implementing a regular scp or rsync over the internet to a home machine was not feasible, as the home machines are not constantly connected. I checked out a few online backup service providers like SpiderOak, BackBlaze and Carbonite. However, for reasons of either cost, lack of OS support and ease of use, I could not utilize any of these.<br />
<br />
On various forums, I saw mention of Amazon S3 as a highly reliable storage option. <br />
However, there was no pre-packaged tool for doing backups to S3. So I decided to roll my own using the Amazon SDK. It looks like Amazon monthly charges are about 1 cent for 2000 files uploaded and a fraction of a penny for each GB stored. For 50GB and 20K files, this likely comes to about $2 per month or less. With a homegrown backup solution and Amazon's highly reliable S3 service, we have a very cheap, very reliable cloud backup solution. <br />
<br />
<h3 style="text-align: left;">
Amazon S3 DIY backup solution</h3>
<br />
1. Create an Amazon Web Services account. This requires you to provide a credit card number. They do have a free service tier (a tiny bit of storage) which provides you the ability to play with the Amazon services for no cost.<br />
<br />
2. From the Amazon console's S3 screen, create an S3 bucket (essentially a directory) that will be the root folder for the backups. Within this bucket, create a sub-folder with the same name as the directory you wish to backup from your machine (keeping the same names keeps things simple).<br />
<br />
3. Create a user account within your main account with correct permissions to read/write to this S3 bucket.<br />
<br />
4. Generate API credentials for this user for use with the Amazon SDK. These credentials are only displayed once. Download them as a CSV and save them. <br />
<br />
5. Install Python-2.6 on the CentOS machine which is required by the Amazon SDK. This requires enabling some alternative yum repositories. The default python on CentOS 5 is Python-2.4 which is not compatible with the Amazon SDK.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$ sudo yum install epel-release</span><br />
<span style="font-family: "Courier New",Courier,monospace;">$ sudo yum update </span><br />
<span style="font-family: "Courier New",Courier,monospace;">$ sudo yum install python26</span><br />
<br /> 6. Download and install the Amazon CLI. This CLI has many different options for interacting with the various Amazon services. Specifically, I wanted to use 'aws s3 sync' for using it to sync all files from the machine to S3.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$ sudo python26 get-pip.py </span><br />
<span style="font-family: "Courier New",Courier,monospace;">$ sudo pip install awscli </span><br />
<br />
6.1. Configure the AWS CLI with the user credentials<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">user@user.org [~]# aws configure<br />AWS Access Key ID [None]: AAAAAAAAAAAAAAAAAAAAAAA<br />AWS Secret Access Key [None]: asdfasdfasdfasdfasdfasdfasdfasdfasfasdfasdf<br />Default region name [None]: us-west-2<br />Default output format [None]: json</span><br />
<br />
<br />
7. Write a few scripts that do the backups to S3<br />
<br />
7.1. Script to dump the MySQL database into a file and compress it. Put the script in cron to make nightly backups and delete backups that are older than 7 days. This way we maintain 7 days worth of database backups on local disk. Recommend doing this in a directory set aside for this purpose. <br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$ mysqldump -u dbuser --password=dbpassword databasename > db_dump`date +%F`.sql</span><br />
<span style="font-family: "Courier New",Courier,monospace;">$ find . -name db_dump\* -mtime 7 -delete </span><br />
<br />
<br />
7.2. Do an initial full sync of top level directory on the machine to S3. This can take hours to run. <br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$ aws s3 sync /home/user/data s3://bucket/data --recursive --quiet </span><br />
<br />
7.3 Write a script to do the same sync and put it in cron. This is the incremental backup.<br />
It's possible to optimize the synch to first use the find command to locate recently modified files and do a copy of these files only. That is:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">#!/bin/bash</span><br />
<span style="font-family: "Courier New",Courier,monospace;">set -e</span><br />
<span style="font-family: "Courier New",Courier,monospace;"># presume the current working directory is to be backed up. </span><br />
<span style="font-family: "Courier New",Courier,monospace;">modified_files=`find . -mtime 1`</span><br />
<span style="font-family: "Courier New",Courier,monospace;">for modfile in $modified_files</span><br />
<span style="font-family: "Courier New",Courier,monospace;">do</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> aws s3 sync $modfile s3://bucket/$modfile --quiet</span><br />
<span style="font-family: "Courier New",Courier,monospace;">done</span><br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/00325244240791275990noreply@blogger.com0tag:blogger.com,1999:blog-3583838516696897626.post-58493487245721837722015-01-02T10:52:00.002-08:002015-01-02T13:19:33.735-08:00New Year Greetings to all contacts<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
New Year Greetings to all contacts</h2>
<br />
As 2014 ended, I figured it was a good time to send out a New Year's Greeting to all of my professional contacts. But, with over a thousand contacts on LinkedIn alone, it would have been a several days of work to compose an email individually. It should be possible to download all of the LinkedIn contacts and then script a custom email to every one.<br />
<br />
<h3 style="text-align: left;">
Step 1: Export LinkedIn contacts </h3>
From LinkedIn Connections, select "Manage Sources" (accessed via the gear icon on the connections page). At the top right, there is a link to export contacts.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNsL7aKTb6NByBrGtvnOf6kN7kmL9JpoqxDc28S4hWNmFms5s8eN12cHu10A4wKcfLif9qQZTmBetxp4cZyYawnpYPHWAuMud68Dp84m9lJsPbUIgpXZ1lZDTaNM1ZEAm1EBe7yT-P6KM/s1600/Screen+Shot+2015-01-02+at+10.32.05+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNsL7aKTb6NByBrGtvnOf6kN7kmL9JpoqxDc28S4hWNmFms5s8eN12cHu10A4wKcfLif9qQZTmBetxp4cZyYawnpYPHWAuMud68Dp84m9lJsPbUIgpXZ1lZDTaNM1ZEAm1EBe7yT-P6KM/s1600/Screen+Shot+2015-01-02+at+10.32.05+AM.png" height="125" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">https://www.linkedin.com/contacts/manage_sources/ page</td><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
Export the CSV file.<br />
<div style="text-align: left;">
<br /></div>
<h3 style="text-align: left;">
Step 2: Script to send a custom email to every contact</h3>
<div style="text-align: left;">
</div>
Really any scripting language could be used, but, I chose Python since I am not using it daily. Like any skills, I need to practice to keep the skill sharp. I wrote this quick script which worked on CentOS, presuming that email is properly configured. Should also work on any Linux variant. <br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">#!/usr/bin/env python26</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">import csv</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">import smtplib</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">import time</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">sender='</span></span><span style="font-family: "Courier New",Courier,monospace;"><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">myemail@domain.com</span>'</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">message="""From: myemail@domain.com</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Return-path: </span><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">myemail@domain.com</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Reply-to: </span><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">myemail@domain.com</span><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">To: {0} {1} <{2}></span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Subject: Hi {0}, Happy New Year 2015</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Dear {0}, Greetings!</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Message you want to send.</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Happy New Year 2015.</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Signature</span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> </span><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">"""</span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-size: xx-small;"># CSV Format: FirstName,LastName,Email</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">f = open('data.csv', 'r')</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">try:</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> reader = csv.reader(f)</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> for row in reader:</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> print row[2] </span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> if row[2] != "": # data.csv may be missing an email address</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> msg=message.format(row[0], row[1], row[2])</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> server = smtplib.SMTP('localhost')</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> server.sendmail(sender, row[2], msg)</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> server.quit()</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> time.sleep(10) # Meter your messages. SMTP relays block messages if too many are sent quickly.</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">finally:</span><br class="yiv3824416560" clear="none" style="background-color: white; color: black; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> f.close()</span></span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">For a thousand contacts, this script will run for about 3 hours sending one email every 10 seconds. </span></span><br />
<h3 style="text-align: left;">
<span style="font-family: "Courier New",Courier,monospace;"><span style="background-color: white; color: black; display: inline ! important; float: none; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">If you run this script, I suggest wrapping it in a nohup command. <b><br /></b></span></span></h3>
<h3 style="text-align: left;">
<span style="font-size: large;"><span style="font-family: inherit;"><span style="background-color: white; color: black; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Step 3: Read replies and respond to them.</span></span></span></h3>
<span style="font-size: small;"><span style="font-family: inherit;"><span style="background-color: white; color: black; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Just because you are able to send bulk New Y<span style="font-family: inherit;">ear gree<span style="font-family: inherit;">ting</span></span> emails, it does not absolve your responsibility to actually communicate with your connections. If I get a <span style="font-family: inherit;">response</span> from <span style="font-family: inherit;">my</span> connection, I <span style="font-family: inherit;">respond <span style="font-family: inherit;">and</span></span> follow up!</span></span></span><br />
<br />
</div>
Anonymoushttp://www.blogger.com/profile/00325244240791275990noreply@blogger.com1