Thursday, July 24, 2008

Creating an Evolution e-mail from the command line and python

Evolution is intended as a GUI e-mail client, so the scripting options are limited. Also, it looks like you cannot autosend e-mail from a script, there's so script command equivalent to the 'send' button.


But that's a good thing; I can autosend from nail when I want to. So a script will compose the e-mail, which will sit on my desktop until I review it and click to send it. Nice.


shell command source

This command creates a window with To:, From:, Subject:, and Body filled in. 'From:' is already known by Evolution, the rest is parsed from the following command:

evolution mailto:person@example.com?subject=Test\&body=Some%20crazy%20story%20stuff%0D%0Acolumn1%09%09column2%09%09column3%0D%0A%0D%0ASincerely,%0D%0A%0D%0AMe


Another (easier) way:
evolution mailto:person@example.com?cc="second_person@example.com"\&subject="This Is The Subject"\&body="This is the body of the message"\&attach=Desktop/test_file.xml
  • evolution mailto:person@example.com - Launches Evolution's e-mail composer and To: line
  • ?cc="Person@example.com" - CC: Line
  • \&subject="Subject" or ?subject="Subject" - Subject line
  • \&body="Body" - Body of the e-mail is everything after this line
  • \&attach=/path/file - Files to attach
  • %20 - Space
  • %0D%0A - CR/LF (new line)
  • %09 - Tab

python command

Python 2.x has it's own smtp module for creating e-mail, it's far more useful in most circumstances. But in this case, we want the composed evolution window.

import os
body_string = 'This is the body of the e-mail message'
body_string = body_string.replace(' ','%20')
os.popen('evolution mailto:person@example.com?subject=Test\&body=' + body_string)
  • import os - Use python's os module
  • body_string = 'This is the body of the e-mail message' - The body in normal text
  • body_string = body_string.replace(' ','%20') - Encode the spaces (evolution will decode them). Tabs, newlines, and other reserved strings need to be encoded.
  • os.popen('evolution mailto:person@example.com?subject=Test\&body=' + body_string) - The 'os.popen(cmd)' executes shell cmd. Note that cmd is just a python string, and you can use all the string tools on it, like adding body_string.
>>> import os
>>> to = 'person@example.com'
>>> cc = '"second_person@example.com"'
>>> subject = '"This is the subject"'
>>> body = '"This is the body"'
>>> attachment = 'Desktop/rss_test.xml'
>>> os.popen('evolution mailto:'+to+'?cc='+cc+'\&subject='+subject+'\&body='+body+'\&attachment='+attachment)

Tuesday, July 22, 2008

Fixing a broken cron job

I am afflicted by Ubuntu Bug #189462, and so I'm getting occasional e-mails from cron that tell me:

/etc/cron.daily/slocate:
slocate: fatal error: load_file: Could not open file: /etc/updatedb.conf: No such file or directory

It turns out to have a trivial solution: touch /etc/updatedb.conf

Update: August 2011 - Finally fixed in Debian.

Saturday, July 19, 2008

What are all these processes?

Trying to figure out all the processes I have running, to see what I can kill, and which packages I can remove.


According to gnome-system-monitor:



System or Root processes I uninstalled,

avahi-daemon - the avahi local discovery system.


System or Root processes I don't use but can't uninstall,
atd                - the at command daemon.
console-kit-daemon - a tracking app for multiuser systems. Many GNOME apps depend on it for some reason.
getty              - console, 6 of them open.


System or Root processes I should keep,
bonobo-activation-server - GNOME component tracker. Safer to leave in place.
gam_server               - gamin tells the window manager about changes in the filesystem.
thunar-tpa               - Thunar trash can applet
evolution-data-server    - database including addressbook and other functions to integrate Gnome app data (breaks Evolution)
evolution-alarm-notify   - alarm clock (breaks Evolution)
system-tools-backends    - DBUS

Thursday, July 17, 2008

Configuring Wine in Xubuntu

Wine 1.0 bugs and fixes.

  • 'Browse C Drive' fails with url not found. This is because Thunar doesn't do bash-style completion, and chokes on a '~' in a config file.

    Fix:
    1. sudo mousepad /usr/share/applications/wine-browsedrive.desktop
    2. Change the line Exec=xdg-open ~/.wine/drive_c to Exec=xdg-open /home/USERNAME/.wine/drive_c
    3. Save and close.

Wednesday, July 16, 2008

Using aria2c for ftp, http, and torrent downloads

Trying aria2c as a command-line replacement for wget, curl, and torrents.

  • Use a new line for each file to download.
  • Use aria2c -D URI for daemon (background) downloads, and free up a terminal window.

Monday, July 14, 2008

Installing DOD CLASS 3 CA-7 security certificate into Firefox 3.0

Superseded by http://cheesehead-techblog.blogspot.com/2015/10/cac-on-firefox-using-ubuntu-1504.html

The US Army has a plethora of websites to keep it's mighty bureaucracy chugging along. Unfortunately, the security certificate they all require is not included in Firefox 3.0 (under Ubuntu 8.04). Here's how to get it and install it.
NOTE: The certificate is worthless to non-DOD people. It doesn't give you access, you still need an account. It's really boring, anyway, and none of the cool secret stuff is in these websites. All the certificate really does for most people is prevent the annoying message: This website has a certificate that I don't trust.
  1. Download the following three files to the desktop:
    • http://dodpki.c3pki.chamb.disa.mil/rel3_dodroot_1024.p7b
    • http://dodpki.c3pki.chamb.disa.mil/rel3_dodroot_2048.p7b
    • http://dodpki.c3pki.chamb.disa.mil/dodeca.p7b


    The easy way in linux is to use curl -O http://dodpki.c3pki.chamb.disa.mil/rel_dodroot_1024.p7b -O http://dodpki.c3pki.chamb.disa.mil/rel3_dodroot_1024.p7b -O http://dodpki.c3pki.chamb.disa.mil/dodeca.p7b

  2. Go to the Firefox Certificate Manager
    • Open Firefox
    • Edit Menu --> Preferences
    • Advanced settings
    • Encryption tab
    • View Certificates button

  3. Import the three new certificates
    (Repeat for each certificate)
    • Authorities tab
    • Click the 'Import' button
    • Show firefox where the downloaded certificate is and click 'OK'

  4. Fix a bug with the CLASS 3 CA-7 Certificate
    • In the Certificate Manager, Authorities Tab, scroll down to the new 'US Government' entries
    • Select DOD CLASS 3 CA-7, and click the 'Edit' button
    • Two of the certificate boxes should be checked. Check them if they are not:

      This certificate can identify web sites

      This certificate can identify mail users

  5. Whew. You're done. Close the windows, restart Firefox and test it.
Importing the same certificates to Evolution is a similar method.

Thursday, July 10, 2008

Messing with the history file

I set the following bash history to make the history file more useful to me.

HISTCONTROL=ignoreboth     #Prevent duplicate history entries
HISTIGNORE=ls:history      #Don't remember these commands in history