Using gammu to connect to a mobile phone

After switching between mobile phones several times I always lost some data, contacts, media, so on…

There is a Linux tool called Gammu which allows to connect a selection of mobile phones. It seems that Gammus functionality is maximal for Nokia and Siemens, but I will give it a try on my Sony Ericsson…

The configuration is not trivial and I found some hints on JohnMcClumpha.org:

Install Gammu

Installing gammu is surprisingly easy (once again thanks to the wonders of apt-get), just use the following command:

sudo apt-get install gammu

Hard wasn’t it? 😉

OK now it’s time to plug your phone in and see if we can get things talking. With the phone connected, type the following command:

lsusb

you should now see your phone listed as a device – for example:

Bus 001 Device 002: ID 0421:0802 Nokia Mobile Phones

if not – make sure your cables and power are all good and try again.

The gammu installation comes with some example configuration files which are worth using as a starting point – if nothing else they help you to understand how gammu can be configured so that you can tailor a solution for your needs. These are located in
/usr/share/doc/gammu/examples
(in gZip archives).

Copy the gammurc file to /etc/gammurc :

sudo cp /usr/share/doc/gammu/examples/config/gammurc /etc/gammurc

Now edit /etc/gammurc to specify your port and connection type (this will vary based upon where/how you have things plugged in and what sort of cable/interface your phone is using). The settings for mine are:

port = /dev/ttyACM0
connection = dku5

Save this config and from the shell type:

gammu --identify

you should now be presented with some information regaqrding your phone such as:

Manufacturer : Nokia
Model : 7200 (RH-23)
Firmware : 3.110 T (18-03-04)
Hardware : 0903
IMEI : 353363000813894
Original IMEI : 353363/00/081389/4
Manufactured : 04/2004
Product code : 0514143
UEM : 16

If this is the case then you have got gammu up and running and can send yourself a test message with the following command:

 echo "boo" | gammu --sendsms TEXT [recipient mobile number]
Advertisement

Restructuring the filetree – moving files from multiple directories

I am considering changing the structure of my /home directory, maybe completely changing my data organisation habbits.

I found this post on ubuntuforums very useful:

You need to use find

For this example I`m going to assume that all the .txt files are located in directories and subdirectories of your Documents folder and you want to move them to a directory in your home called scripts
Code:
find ~/Documents -name '*.txt' -exec mv '{}' ~/scripts \;

Remove U3 System from SanDisk

Bought a SanDisk Cruzer 16GB and found some smart software preinstalled which did not consider smart at all. Everytime I inserted the drive on any computer a CD drive with label U3 System“was mounted containing some funny .exe files. The whole “CD drive” took several MB of diskspace.

I wanted to get rid of it. Fortunately, I was not the first one beeing disturbed.

Sourceforge has a u3-tool which did the job:

  1. Download the tool to a place where you remember it
  2. Unpack the .tar.gz archive (I just rightclicked it and chose “extract here”). This creates a folder like /MyPathTo/u3-tool-0.3/
  3. open a terminal and type: cd /MyPathTo/u3-tool-0.3/
    ./configure
    make
    sudo make install

    Now u3-tool is installed and can be used.
  4. To remove the CD-like partition containing the firmware crap you need the device name of the USB disk: sudo fdisk -l gives the answer. In my case it is /dev/sdb1. Make shure you remember the right one.
  5. Remove the U3 partition with u3-tool -p 0 /dev/sdb1where /dev/sdb1 is the device name remembered from the previous step and the option -p is followed by a zero.

Done.

Passing an external variable to AWK

Confronted with a heap of colon separated text files which had to be merged and cleaned of unrelated lines and columns, i tryed my luck inside Excel and spend a lot of time doing it manually, but finally got fed up.

So I decided to use AWK on the task.

A FOR-loop lists the files in the folder into the UNIX pipe.

AWK selects the non-empty observations and adds the name of the file as a classifier to the beginning of the line (the result is a repeated measure dataset).

This is the code:

for CSV in `ls`
do
cat $CSV | awk -F ";" '{
if ($2 ~ /[0-9]+/) {print CSV , FS , $0;}}'
done

Remark: -F ";" option specifies how to distinguish the columns/fields of the lines/records in the file(default is ” ” or empty space).

BUT: The variable CSV gets not passed to AWK by default it has to be fed into AWK.

Solution:
The
-v CATEGORY=$CSV
option feeds the external variable CSV into the AWK-variable CATEGORY.

This gives:
for CSV in `ls`
do
cat $CSV | awk -F ";" -v CATEGORY=$CSV '{
if ($2 ~ /[0-9]+/) {print CATEGORY , FS , $0;}}'
done

.. and works 🙂

Hat tip:fpmurphy

Xubuntu Desktop Disappeared

The other day my desktop disappeared in Xubuntu Karmic (9.10). First I did not notice since the background was still visible, but no icons showed up (which I rarely use, appart from removable media) and the very useful middleclick showing all processes on all desktops did not work anymore.

Took quite some googling, but Ubuntuforums had the answer:

Alt-F2 to open the application starter and
xfdesktop
started the desktop process again…

The desktop process must have failed the other day and after exiting the session this configuration was safed… even restarting did not change it.

Xrandr – Manipulating Monitor Setting via Command Line

Usually Ubuntu and all of its derivatives would recognize an external monitor and set it up reasonable automatically. At least all the flavours I tried of Ubuntu, Xubuntu, Linux Mint did that – with Linux Mint most ellegantly – in my opinion.

I read some warnings that one should be prepared for “regressions” in connection with some development issues in Karmic Koala.

So:

Second (external) display does not work as used to anymore. After Xubuntu Karmic Koala fresh install I found just “Display1” in the Display settings. I could set it to the (higher) resolution 1280×1024 of the external display, but then my Lenovo X61s laptop display (1024×768) would turn black.

A workaround was not so hard though:
xrandr
in the command line showed that both the laptop display (“LVDS1”) and the external display (“VGA1”) were detected and running; just that the external display was running at laptop resolution too.

Xrandr did even detect the optimal settings for the external display.

Thus
xrandr --output VGA1 --auto --above LVDS1
set the resolution and refresh rate of the external monitor correctly and put it as an extended Desktop “above” the laptop screen. Exactly the way I did like it in Linux Mint 7 before…

Xrandr is commandline interface “to set the size, orientation and/or reflection of the outputs for a screen” (from the man page).

In Ubuntu
man xrandr gives a short description with examples. I derived my workaround from one of the examples given.

Managing Amazon S3 Online Storage with S3sync

After trying to use Amazon’s S3 web service to backup files and to get a reliable download area for R functions and stuff which is not allowed to be uploaded to wordpress.com I ended up with some experimental “buckets” (= S3 online directory) and some 100 MB of files in them.

It turned out that it is not possible to delete a non-empty bucket from S3, so one is to required to recurse into the directories and delete all files one by one!

Eric Cheng and other blogs appearing after a google search pointed out S3sync as a suitable tool to remove a non-empty bucket.

So first one has to get Ruby and then also the OpenSSL interface for Ruby: sudo aptitude install ruby libopenssl-ruby

Then download s3sync (to your /home/yourself folder in this case) and unpack it: cd $HOME/
wget http://s3.amazonaws.com/ServEdge_pub/s3sync/s3sync.tar.gz tar xvzf s3sync.tar.gz
rm s3sync.tar.gz

This creates a s3sync folder containing the ruby code.

The package ca-certificates includes PEM files of CA certificates to allow SSL-based applications to check for the authenticity of SSL connections. It is needed to have the S3 connection secure via SSL and part of the default Ubuntu installation (at least included in my Xubuntu Karmic Koala. If not: sudo aptitude install ca-certificates

Before using s3sync get your access key and secret access key from Amazon. It has to be included in a file “s3config.yml” which is located in your home folder inside the directory “.s3conf” which has to be created. So:

mkdir $HOME/.s3conf
to create the directory.

Open your favorite text editor and create a plain textfile called s3config.yml inside the “.s3conf” folder which contains: aws_access_key_id: YourS3AccessKeyFromAmazon
aws_secret_access_key: YourS3SecretAccessKeyFromAmazon
SSL_CERT_DIR: /etc/ssl/certs

Prevent others from reading the configuration file containing your confidential access codes by chmod 700 $HOME/.s3conf/s3config.yml

Now you can start to use s3sync and s3cmd to manipulate your S3 storage space with e.g.: ruby $HOME/s3cmd.rb listbuckets

This was the first time I managed to manipulate successfully my S3 account. Ok, Djungledisk under Mac OS-X worked, but it is proprietary, though not expensive.

John Eberly’s blog was an inspiration to get started. Follow the link to his excellent blog post.

Mount a CD Image on Harddisk

A copy of a CD containing e.g. installation software or a game (so called iso image) can be mounted directly from the harddrive. This might be useful to mimic a CD without inserting the CD into the (very slow and power consuming) CD/DVD-drive.

1. Create a mountpoint e.g. in the /media directory:
sudo mkdir /media/iso

2. Mount the image MyCDimage.iso as a CD:
sudo mount -t iso9660 -o loop MyCDimage.iso /media/iso

3. Display all filesystems to check its mounted:
df -h

In order to play e.g. Windows games with wine the mountpoint /media/iso has to be added as a drive under wine.
winecfg
choose the drive tab and add /media/iso

Slow Filetransfer under Linux

After all Bill Gates has also an issue to prey on: Linux seems to be quite unefficient in transfering files from one partition (or harddisk or USB-disk) to another.

I asked for an explanation on the Linux Mint Forum.

‘optimize me’ came up with an interessting answer, which I just quote:

There is some long standing problems with how file transfers work. I never had a problem with it until kernel 2.6.24-19 came out for Ubuntu Hardy Heron back in June of 2008. At first, all I noticed is that file transfers to USB devices (flash drives, external HDDs) started moving slower than molasses in winter. CPU usage stayed below 15% or so, but transfers never went faster than 5MB/s and the speed always degraded to tens of K/s.

Research I did shows that this has been a problem on various distros going as far back as 2005. Over time, I’ve discovered that this bug is not limited to just moving files to USB devices, but also affects moving files between partitions on the same hard disk, and also affects network file transfers (both SMB & NFS).

If you look at your system monitor in the panel (I assume that’s what you’re using), and change the color scheme of your CPU monitor(s) to highly contrasting colors (Red, Blue, Yellow & Green, for example), you’ll see that what’s termed as “I/O Wait Time” is what’s eating up all your power. I’ve been up and down a million forums, been in contact with kernel and module developers, and spent countless hours researching the problem.

I’ve got zilch.

All I can tell you is that the problem doesn’t effect everyone – only, it seems, a small minority – so it’s not at all a priority for the developers to fix. You can do a google search for “slow+usb+linux” or “slow+usb+ubuntu” and you’ll probably find all my forums posts and all the same info I found. I’m not a programmer, I’m not a developer, and I don’t know jack about where to even begin tackling this problem. That’s where that stands.

I inserted some linebreaks for readability. Thanks a lot ‘optimize me’.

No Sound on HP EliteBook with Ubuntu Jaunty

Sound did not work on a HP EliteBook 2730p. It seemed the sound did not reach the speakers. I found the solution at linlap.com for the EliteBook 2530p and some Linux distribution. It worked on the 2730p as well:

Open alsa-base.conf with any texteditor (here ‘gedit’) by typing
sudo gedit /etc/modprobe.d/alsa-base.conf
in the terminal.

Then add a line
options snd-hda-intel enable_msi=1 single_cmd=1 model=laptop
at the end of the file.

Save it and restart the computer.

PS: This is one-of-those-Newbee-with-Linux-problems which get solved by semi-competent replication of some geeky fiddling with foo.conf files in /etc or /boot or /bar folders … I have no Idea what alsa-base.conf is and why/how this works. I just found the fix with google at the site cited above and it works…