Tag: Linux

  • FreeTDS is a bag of razorblades use, Microsoft ODBC Driver for Linux instead

    According to @mst FreeTDS is a bag of razorblades.
    That’s right folks, don’t use it. The new way to go is Microsoft ODBC Driver for SQL Server on Linux.
    Unfortunately its a nightmare to install on debian. Luckily some very smart people wrote a lovely little howto: Install and Configure the MS ODBC Driver on Debian.

  • Printing from Windows to a samba shared CUPS-PDF printer sometimes fails

    Printing from Windows to a samba shared CUPS-PDF printer sometimes fails

    I had this problem where prints to our CUPS-PDF printer sometimes failed to be processed on the server. The job would disappear as though it has been printed but nothing else would happen. Printing from the same application to a Windows based PDF printer, and then printing the resulting PDF via Adobe Acrobat to the CUPS PDF printer would work fine. Printing the same PDF via Sumatra PDF to CUPS-PDF would also fail.
    Further investigation revealed that the resulting print job files would differ. The jobs that fail looked like they contained a lot of binary data but the ones that succeeded looked like normal PDF files.
    Then I discovered this entry in the Windows Event Viewer:

    The document XXXX, owned by jason, failed to print on printer \\server\PDF. Try to print the document again, or restart the print spooler.
    Data type: NT EMF 1.008. Size of the spool file in bytes: 2555904. Number of bytes printed: 0. Total number of pages in the document: 1. Number of pages printed: 0. Client computer: \\CLIENT. Win32 error code returned by the print processor: 0. The operation completed successfully.

    Googleing that error took me to this RPi forum which had a solution buried down near the bottom. Thanks to Chemirocha for that tip. This bug has been plaguing me for a few years on and off!

  • automysqlbackup ERRORS REPORTED: MySQL Backup error Log Warning: Skipping the data of table mysql.event. Specify the –events option explicitly.

    automysqlbackup ERRORS REPORTED: MySQL Backup error Log Warning: Skipping the data of table mysql.event. Specify the –events option explicitly.

    I was receiving email error messages from cron like this from my autbackupmysql on a regular basis:
    ERRORS REPORTED: MySQL Backup error Log for somehost.com.dxa - 2014-05-01_06h26m
    -- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.

    It turns out that mysqldump now warns you if the events table is not being dumped. So to get rid of the warning either ensure the table gets dumped when you do a backup or tell mysql explicitly not to dump it. I chose the former approach as it is a backup after all.
    Simply add the following line to /etc/mysql/my.cnf

    [mysqldump]
    ...
    ...
    ...
    events

    This tells the mysqldump program to explicity include the events table, and removes the warning. You can see a discussion about this option here.
    If you are using debian, you will need to add that section to the /etc/mysql/debian.cnf file also as automysqlbackup uses that file for its configuration instead. See debian bug report for more details.

  • HP MediaSmart IR Remote for MythTV

    HP MediaSmart IR Remote for MythTV

    I’ve been on a quest to find a good remote for MythTV. My first try was with a Logitech Harmony. Those things are nasty horrible pieces of crap. I’d never touch one again. Programming it is a nightmare. It does not have a generic PVR option so you have to fake it to make it work with Mythtv by telling it its another device and learning those codes in LIRC. It is a very slow device with what felt like a 500ms delay with each keypress. It also tried to know what state your equipment was in so that it could turn things on and off, but of course it would always be out of sync and then you’d have to go through this process of turning things on and off until it was in sync again.
    Enter the HP MediaSmart IR remote, also known as HP RC2285202/01. These devices used come with a media player box that HP used to sell. As far as I can tell, its not in production anymore but the remotes are readily available on Ebay.
    Features:

    1. Dedicated IR codes for the PVR. On previous universal remotes I have used, I was unable to find a “code” setting that would make all the buttons active, that I could then learn in LIRC.
    2. Back-lit keys. All the keys seem to be backlit. Some universal remotes either only backlight a few keys or have no  backlight at all.
    3. Cheap. A$23 with USB receiver, delivered.
    4. Universal remote. Can control 5 devices including your PVR.
    5. Punch Through. Some buttons like volume and mute can punch through from the TV or Amp, to the PVR device. IE. you can make it turn the volume up on the amp when you press the volume button when in PVR or TV modes.
    6. Takes standard AA batteries.

    There are a few downsides too:

    1. Difficult to get going (solved now that you have found this blog post)
    2. Punch through does not work on all buttons.  Namely Power and Source. This is annoying but solvable with a pulse-eight CEC adapter

    I spent many hours trying to work out why it would not work on my system. In the end it came down to two things.
    For some reason LIRC does not work correctly with MCEUSB receivers that are plugged into USB3 sockets.
    You need to tell the kernel to treat the receiver as lirc rather than anything else, in order for LIRC to be able to connect to it:

    $ sudo sh -c "echo lirc > /sys/class/rc/rc6/protocols"
    $ sudo cat /sys/class/rc/rc6/protocols
    rc-5 nec rc-6 jvc sony mce_kbd [lirc]
    

    The word [lirc] surrounded with square brackets tells you it worked.
    I implemented this at boot time by adding

    /etc/rc-scripts/start-lirc
    

    to /etc/rc.local and then in /etc/rc-scripts/start-lirc

    #!/bin/bash
    echo "Making lirc the default for rc"
    echo lirc > /sys/class/rc/rc0/protocols
    echo "Starting lircd"
    /etc/init.d/lirc start
    

    Remove lirc from the normal startup process:

    $ sudo update-rc.d lirc remove
    

    Test your configuration (retrieve HP-RC2285301-01.conf below):

    $ sudo /usr/sbin/lircd -n -d /dev/lirc0 -P ./lirc.pid  HP-RC2285201-01.conf
    $ irw
    

    And when you press the keys on your remote, you should see some output from irw.

  • How to make a bootable usb stick in Windows 7 of a debian iso

    Every so often I need to make a bootable USB stick in Windows 7 (64 bit) of a debian installer iso. For some reason my googling usually does not reveal a simple solution for this.
    I asked on #debian on the OFTC network and got various suggestions. The first suggestions were to use win32 compiled variants of dd or rawwrite. The problem is that there seems to be multiple versions of these tools out there and the ones I tried all seemed to have issues of one sort or another, mostly to do with dd complaining that it would not run on 64 bit Windows. My other issue is that they are command line based. Not that I mind using the command line but it does feel fiddly when all you want to do is get on with writing the image to the USB stick so you can install Debian.
    Next I came up with unetbootin. This looks promising and seems to work but it does some very strange rewriting of the boot menus you get on the resulting USB stick. I was confused by the menus when I first saw it and I’m sure novice users would have no idea what to do.
    Finally dvs on #debian suggested win32diskimager. This is exactly what I wanted. A point and click solution.

    screenshot of win32diskimager
    screenshot of win32diskimager

    Select the DVD image you want. If the file’s extension is .iso you’ll need to change the filter from *.img;*.IMG to *.* in order to see the file. Then select the Device you want to write to. Hit Write and go and have a cup of tea while it writes the ISO to the USB stick.

  • Project Euler No. 1 in Emacs elisp

    My first Project Euler solution, and my first emacs elisp program.
    Multiples of 3 and 5.
    If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
    Find the sum of all the multiples of 3 or 5 below 1000.
    My solution:

      (defun divisibleby (dividend divisor)
        "check if dividend is divisible by divisor"
        (if (not(integerp dividend))
            (error "dividend must be an integer"))
        (if (not(integerp divisor))
            (error "divisor must be an integer"))
        (zerop (mod dividend divisor))
        )
    (let  ((lower 1)
           (upper 1000)
           (sum 0))
      (loop for i from lower to (- upper 1) do (if (or (divisibleby i 3)
                                                  (divisibleby i 5))
                                             (setq sum (+ sum i)))
            )
      (message "sum is: %d" sum)
      )
    
  • Error: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ExecFailed: Failed to execute program /usr/lib/dbus-1.0/dbus-daemon-launch-helper: Success

    I recently migrated my linux box from bare metal hardware to a VMware virtual machine. At the same time, I upgraded from Debian squeeze to Debian Wheezy (testing).
    After the dust had settled, one nagging problem keep recurring. Every time I did an aptitude update or aptitude install, after everything successfully ran, I would get this error message:
    Error: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ExecFailed: Failed to execute program /usr/lib/dbus-1.0/dbus-daemon-launch-helper: Success
    The cause of this proved quite difficult to track down. Eventually a Gentoo forum post led me to the solution. It seems that somewhere along the line, dbus-daemon-launch-helper has ended up with the wrong permissions. Change its permissions to be world executable.
    chmod o+x /usr/lib/dbus-1.0/dbus-daemon-launch-helper

  • ping with timestamp

    I couldn’t work out a way to get ping to print a timestamp of when the ping took place. For some reason it seems as though this isn’t a sought after feature.
    Luckily you can achieve the same thing using fping:

    while [ 1 ] ; do echo $(date '+%F %T') $(fping -e google.com); sleep 1; done
    

    Gives the following output:
    2008-03-18 11:06:54 google.com is alive (250 ms)
    2008-03-18 11:06:56 google.com is alive (248 ms)
    2008-03-18 11:06:57 google.com is alive (268 ms)
    2008-03-18 11:06:58 google.com is alive (250 ms)
    2008-03-18 11:07:00 google.com is alive (250 ms)