Friday, August 29, 2008

Fast File Sharing from Ubuntu

Command line Python 2.6 tool to set up an instant FTP server:

Open a terminal

cd /path/to/directory-I-want-to-share
python -m SimpleHTTPServer # Python 2.x only  starts the server on port 8000 
python3 -m http.server     # Python 3.x only  starts the server on port 8000
  • Minimize the terminal window so you don't accidentally close it.
  • Sharing is one-way; no uploading. No security. The entire contents of the directory are shared; no blocking. No logging (that I know of). Just pure download server. Cool.
  • Other computers access the server by web: http://xxx.xxx.xxx.xxx:8000
  • Your computer accesses the internal server by web: http://xxx.xxx.xxx.xxx:8000 or http://localhost:8000.
  • Kill the process CTRL+C to stop the server

Friday, August 22, 2008

Opening a terminal window using cron

Fast experiment to use cron to open a terminal window and execute a command. Success!

The crontab item is:

* * * * * DISPLAY=:0.0 /usr/bin/xfce4-terminal -x top
     # * * * * *               - the crontab time codes. Substitute your own.
     # DISPLAY=:0.0            - sends the subsequent commands to the screen
     # /usr/bin/xfce4-terminal - the application (opens a terminal window)
     # -x top                  - execute the top command in the application
Once a minute, a new terminal window spawns running 'top', just as intended.

Saturday, August 16, 2008

AbiWord Spell Checker on Xubuntu 8.04

AbiWord doesn't come with a spell checker installed...but it doesn't tell you that.

Here are the packages to install the spell checker: (source)

  • aspell
  • aspell-en
  • libenchant1c2a

Use Synaptic or the command line to install. Restart AbiWord, and Presto...now it works.

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.