rblog

Mac OS X: Yet another update on the issue of corrupted home folder

After successfully getting access to all my files using the install DVD I did a reinstall. When finished I created a user with the same user id as before. Then logged on and became a bit confused by the fact that it had the same wallpaper as before the crash. Turned out that the reinstall had not deleted anything in the old home folder, and when creating an identical userid I got access to all the old files.

A bit surprised by the fact that a complete reinstall is not really what I thought it should be, but hey…who cares right now!!!

Mac OS X: No need to kick it….yet!

Must admit that I’m still mad because our Macbook Pro decided to crash and not give me access to all our files, but at least I’ve just found a workaround.

Using the Install DVD, insert it and reboot while holding the c-button (makes your Macbook boot from CD/DVD). When the menu appears, from Utilities choose Terminal. With root privileges you have full access to the disk. Then insert a memory stick with enough space and voila. You will find both your memory stick and your hard drive in the folder /Volumes

Using copy (cp) you can copy all the files missing, and a voila…just reinstall the whole thing…and then up and running again.

Still pissed that the home folder got corrupted, but at least I managed to save all the files which I did not have a backup of (I rule!!!)

Mac OS X: Can I kick it?????

“….The file system directory in any of these disk image formats can become corrupted. This is usually as the result of an improper shutdown….”

http://www.thexlab.com/faqs/fixfilevault.html

Improper shutdown my ass!!! Yesterday evening I started my rsync-script which moved about 50 GB of flac-files from our MacBook to the external disk, which I have done many times before. Also knowing that after a period of inactivty after the script have finished the Mac would do a shutdown. No problem at all. So this morning I got up and wanted to unmount the disk, but for some reason it would not accept my well known password. After a few tries I rebooted the machine and voila…no account other than the guest account was available.

Did some research during the day and realized that I would maybe have been able to get around the problem if logging in using another account and then enable root…but…using the guest account, seems impossible. Fu¤%!!

Luckily I do not think we have lost much data, but am I really pissed – YES!!! We have bought according to my standards an expensive computer with an operating system as expensive as the hardware, and then I find info saying “…disk image formats can become corrupted…”. If it had been my Linux-distro which I have costed me…zero…I could have managed, but OS X…aaaaarrrghhhh!!!

So complete reinstall seems to be the only way…shoot!!!

Groovy XML-script that is copying elements and changing attribute values

Based on all the good examples provided by http://groovy.codehaus.org/ I’v managed to create a Groovy script that do

  • Find all elements with a name attribute prefixed with ‘DEV_’
  • For all found elements, search for element with identical name attribute, but without prefix ‘DEV_’. If element found, remove it
  • Create a copy of the element with the ‘DEV_’ prefix and then
    • Remove the prefix
    • Change the value of the attribute driver
    • Add the copy to the list of cars
  • Write the updated XML to file

Click more to view the script. Sorry for the limited display of code in my blog.
[teaserbreak]


import groovy.xml.DOMBuilder
import groovy.xml.dom.DOMCategory
import groovy.xml.dom.DOMUtil

class CarExamples {
static def CAR_RECORDS = '''
    <records>
      <car name='HSV Maloo' make='Holden' year='2006'>
        <country>Australia</country>
        <record type='speed'>Production Pickup Truck with speed of 271kph</record>
      </car>
      <car name='P50' make='Peel' year='1962'>
        <country>Isle of Man</country>
        <record type='size'>Smallest Street-Legal Car at 99cm wide and 59 kg in weight</record>
      </car>
      <car name='Royale' make='Bugatti' year='1931'>
        <country>France</country>
        <record type='price'>Most Valuable Car at $15 million</record>
      </car>
    </records>
  '''}

def reader  = new StringReader(CarExamples.CAR_RECORDS)
def doc     = DOMBuilder.parse(reader)
def records = doc.documentElement

use (DOMCategory) {

	println "There are " + records.'*'.size() + " cars defined in the file"
    def cars = records.'car'
	println "The parent element for cars are " + cars[0].parent().getTagName()
    def dev_cars = cars.findAll{it."@name".startsWith("DEV_")}
	println " "
	dev_cars.each {
		def nameofdev = it."@name"
		println "Dev name: " + nameofdev
		def stringArr = nameofdev.split("DEV_")
		def deleteMeName = stringArr[1]
		println "Node to remove has name: " + deleteMeName
		def deleteRecord = cars.find{ it.'@name' == deleteMeName }
		if (null != deleteRecord) {
			records.removeChild(deleteRecord)
		}
		def copyOfDev = it.cloneNode(true)
		copyOfDev.setAttribute("name", deleteMeName)
		copyOfDev.setAttribute("driver", "racer")
		records.appendChild(copyOfDev)
		println "\n"
	}
}

outputFile = new File("resultfile.xml")
outputFile.write(DOMUtil.serialize(records))

Groovy startup error on Windows

Trying out Groovy on my laptop running Windows XP and kept getting the errormessage:

error: could not find client or server jvm under C:\apps\IBM\SDP\jdk\bin
please check that it is a valid jdk / jre containing the desired type of jvm

JAVA_HOME was set, tried to add the path to the jdk, but still did not help. Then found the solution at …startup-error-….html. Problem was that when issuing the command ‘groovy’ alone it runs the groovy.exe, but the .exe-file does not handle the paths correct for some reason. Running groovy.bat fixes the problem since it handles the paths correctly.

What (REALLY) caused my svn checksum mismatch problem

My previous post with almost the same title “What caused my svn checksum mismatch problem described the root cause to my problem, the perl search/replace command, but I did not understand what why the perl command

perl -pi -e ‘s#ojdbc14_10.2.0.2.jar#ojdbc6_11.1.0.7.0.jar#g’ `find . | grep jdbc.xml`

created the svn mismatch-problem. Thanks to input from Geir Sjurseth we got it figured out. Should really have figured it out by myself, but as many times before, I’m blind to the solution and need someone just to get me to view the problem from another angle, then the solution is as easy to find as the sun on the sky (or whatever analogy would be appropriate).

The problem is the
`find . | grep jdbc.xml`
command which would also change jdbc.xml-files in the .svn-folders. Changing the entire command to for instance
find . -name jdbc.xml -exec perl -pi -e ‘s#ojdbc14_10.2.0.2.jar#ojdbc6_11.1.0.7.0.jar#g’ {} \;
solves the whole problem. -exec is also preferable I’ve learned since that would not create a child process (fork)

Things to do on a Sunday evening

vi + name of file
shift + G (Goto last line in VI)
o (insert after line in VI)
Middle mouse button (paste in X-WIN32)
ESC (quit insert mode in VI)
shift + ZZ (Save and exit in VI)
…next file, times 140
All because SVN looses control when using perl search/replace

Good thing that I have Spotify and can use the time to get to know “Darkness on the edge of town”

What caused my svn checksum mismatch problem

@Update: See post 2011/01/17/what-really-caused-my-svn-checksum-mismatch-problem for final solution

Have been struggling with svn checksum mismatch problem which is annoying, but no show stopper due to the problem being possible to solve by workarounds as described in this blogpost glob.bushi.net.nz/…/subversion-checksum-mismatch-easy-workaround/

But still, I needed to figure out what the root cause was, and it turned out that the Perl search/replace was the sinner.
Issuing the command

perl -pi -e ‘s#ojdbc14_10.2.0.2.jar#ojdbc6_11.1.0.7.0.jar#g’ `find . | grep jdbc.xml`

then verifying the change by looking at the file using VI. But when issuing

svn status

svn was not able to see any changes. Then I added a xml-comment describing the change, saving and then svn commit I got the checksum error. After doing the workaround and then editing the file all manually, not issuing the Perl-command…voila, no problem. Have not been able yet to figure out why svn don’t like Perl search/replace changing the file…not sure if the -pi -e could be causing the problem, but I’m quite sure it has been accepted before.

NRK on Apple Tv (v1) using XBMC 10.0

Last week I had some struggle trying to enable NRK Nett-TV. The patchstick I had used installed XBMC 9.11, and I found the plugin described in this thread on freak.no. Could not get it to work, suspecting the mplayer-version causing the problem.

So I restored the box using factory restore, then created a patchstick by using the magical piece of software created by the guys behind atvusb-creator. A lot of cursing at first, since none of my usb-sticks would load (Kingston 8Gb), and also another stick of unknown make. Got to borrow a stick from Lars Tormod, one of many of a unknown make he had been handed at some event – but it did the trick. Patch booted, and now I’m running XBMC 10.0. In the list of video addons there is an addon named NRK…installed it and now out the box, we have NRK Nett-TV on our tv using the Apple-TV.

Also – remember to install Nito TV, then goto Settings –> Install Software –> Smart Installer. Thanks to http://www.todaywasawesome.com/enable-usb-on-the-apple-tv/ for reminding me by providing the post found when desperatly searching for help when my usb hard drive was not found. Note, you do not need to download up front, Smart Installer fixes that for you.

Find text between double brackets using regex

Just needed to post this one as a reminder to myself. Once in a while I need to update text between double brackets, often values of parameters like the case now

password="thepassword"
...
password="yetanotherpassoword"

Having a lot of this makes it annoying to update it manually, but by using Notepad++ which also have a regex-search-replace option it is easy

password=".*"

did the trick for me.