vendredi 17 décembre 2010

Fixing modification dates on photos using the creation date in the photo file (set by the camera)

I have a large collection of photos, several dozens of Gb and I accidentally copied them without preserving the orginal creation dates.

Every photo you take has a date set in the file by the camera in what is called exif metadata. Some cameras can also record the exact coordinates where the photo was taken ... anyway, I needed to fix those dates. I also like to keep the files in a year/month/day folder structure.

So, here is my script:

#!/bin/sh

DATE=`exiftool "$1" | grep 'Create Date' | sed -e 's/.*: //;s/://g;s/..$//;s/ //g'`

DEST=`echo $DATE | sed 's@^\(....\)\(..\)\(..\).*@/media/shared/Pictures/\1/\2/\3/@'`
touch -t $DATE "$1"

if [ -d "$DEST" ]; then
cp -an "$1" "$DEST"
else
mkdir -p "$DEST"
cp -an "$1" "$DEST"
fi

vendredi 10 décembre 2010

Windows XP SP3 Installation fiasco

So, here I was again, creating a new vm for Windows XP. I have a Windows XP SP3 iso from work I use. This is my work computer and we have a volume license. Anyway, legal all the way.

So I insert the cd, it installs fine and the first thing I do is start Windows Update. It needs to install 85 updates totaling 107 Mb and claims it will take 51 minutes with my connection ... it took about 15 minutes including installation ... although only 82 were installed, the other three were skipped (I guess they needed a reboot).

Anyway, on the reboot, it keeps restarting as soon as it gets to the blue background. Not the BSOD background, the somewhat lighter background before the Welcome page loads.

Safe mode works without an issue, so I somehow suspect graphics driver issues, remember this is a vm - and I enabled 3d. So I try VGA mode, and there I briefly see a bsod. So I disable the automatic restart on error, and the fucker does not allow me to switch to another mode, like VGA.

So, instead of seeing the blue background I see a higher resolution black background with an hour glass. Go figure ... anyway, go back to the startup options and select "Last Known Good", which I did not feel too comfortable with, since I just installed a whack of updates and this is still the first restart after that massive install .... but I get to the desktop, youpie!!!

But the fun is not over, it wants to send an error report, which is fine by me ... and the error report is corrupt!!!!

So, I know it wants to install the other three updates and I shutdown Windows (Start -> Shutdown)... and it installs the updates. After that I get back into the same loop ... I select Last Known Good and it works ... bloody hell, how do people put up with this I do not know ... And this Last Known Good does not sound right to me ... updates have certainly changed the services and drivers ... ohh my ... I am unsure what to do now. I probably should not have installed the vm tools before the updates? Go figure.

I guess I am condemned to select Last Known Good after every software update .... fsck!

Before you ask, I need Windows XP for work ... sometimes ... and my 5 year old vm was getting issues with disk space, so I decided to install a new one from scratch.

I like the irony of "Last Known Good" ... that should uninstall Windows ....


I go back to windows update, and it wants t install another 7 updates, which I install ... after that, I get back into the looping booting fiasco ... Last Known Good ....

mardi 28 septembre 2010

chroot java on linux x86_64

I had to chroot java on linux 86_64. I have found many blogs, but all I read missed some of the steps:


export JAIL=/home/jail
#Make all dirs 
mkdir -p $JAIL/dev $JAIL/lib $JAIL/etc $JAIL/opt/ $JAIL/proc
#copy hosts file
cp /etc/hosts $JAIL/etc/hosts
#copy libs required by java (1.6.20) 
cp /lib/ld-linux-x86-64.so.2 /lib/libc.so.6 /lib/libdl.so.2 /lib/libgcc_s.so.1 /lib/libm.so.6 /lib/libnsl.so.1 /lib/libpthread.so.0 /lib/librt.so.1 $JAIL/lib/ 
#needed by my Java app
cp /usr/lib/libstdc++.so.5 $JAIL/lib/ 
#Although you link this to your "real" /lib, in your jail, it will be the lib directory in your jail.
ln -s /lib $JAIL/lib64
#Mount proc 
sudo mount -t proc /proc $JAIL/proc
#create devices 
sudo mknod -m 666 $JAIL/dev/random c 1 8 
sudo mknod -m 666 $JAIL/dev/null c 1 3 

sudo mknod -m 666 $JAIL/dev/zero c 1 5

Now just copy/install java, then start it with:
sudo chroot $JAIL /opt/java/bin/java -version
Assuming that /opt/java is where you installed java.
If java does not launch, make sure with ldd, that all so files are in the $JAIL/lib dir.
I got
chroot: failed to run command `/opt/java/bin/java': No such file or directory
Because the lib64 directory was not linked to /lib.


I see quite a few people like this blog post, please leave a comment ... thanks.

mercredi 8 septembre 2010

SQLPLUS command history

I was using sqlplus on Linux and needed command history. I looked around the net and found rlwrap.

To my surprise, it was even in Debian's apt repositories!

$ sudo apt-get install rlwrap

worked like a charm.

To use the program:

$ rlwrap sqlplus scott/tiger@orcl

I finally went for gqlplus, beacuse it is even better; it has table name completion, like the bash shell does for files & folders. It needs libncurses-dev. You should read the readme, do not perform make install, just copy the gqlplus binary into your path. Note that sqlplus must be on the path as well.

I created an alias named sqlplus that runs gqlplus.

vendredi 16 juillet 2010

Convert Office Documents to PDF from the command line

I prepare training courses and often have to convert 90+ Word documents to PDF.
I have Adobe Acrobat Professional and found no quick and easy way to do it. I used vbs before and it was so slow, OpenOffice converts all documents faster than vbs can convert 2 of them. I guess it would be even faster if we were using openOffice formats ... which I am investigating ...

So I use OpenOffice for this, with two nice macros I "stole" from Sun^H^H^HOracle.

Here they are:


REM -------------8<-------------8 span="">
REM ***** BASIC *****

Sub ConvertWordToPDF(cFile)
cURL = ConvertToURL(cFile)

' Open the document.
' Just blindly assume that the document is of a type that OOo will
' correctly recognize and open -- without specifying an import filter.
oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))

cFile = Left(cFile, Len(cFile) - 4) + ".pdf"
cURL = ConvertToURL(cFile)

' Save the document using a filter.
oDoc.storeToURL(cURL, Array(MakePropertyValue("FilterName", "writer_pdf_Export"), ))

oDoc.close(True)

End Sub

Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
REM -------------8<-------------8 span="">


Now here are my shell scripts, both Windows and Unix:

Windows
REM -------------8<-------------8 span="">
rem DIR=$(pwd)
rem DOC=$DIR/$1
REM The following two lines are on one line!
for /r %%i in (*.doc) do swriter -invisible "macro:///Standard.Module1.ConvertWordToPDF(%%i)"
REM -------------8<-------------8 span="">

Unix

#-------------8<-------------8 br="">#!/bin/sh DIR=$(pwd)
DOC=$DIR/$1 PDF=`echo $DOC | sed 's/...$/pdf/'`
if [ ! -e "$PDF" ] ;
then
#The following two lines are on one line!

soffice -invisible "macro:///Standard.Module1.ConvertWordToPDF($DOC)"
echo "Processing $DOC"
while [ ! -e "$PDF" ] ; do
sleep 3;
done
fi
#-------------8<-------------8 span="">

On Unix I run

find /some/path/to/documents -name -exec doc2pdf {} \;

The reason I need the while loop on Unix is because soffice does not wait until the macro has finished and goes on to convert the next file. OpenOffice errors out on my system, it cannot process two files simultaneously ... sad, that!

mardi 18 mai 2010

SQL Server installation

So, I install MS SQL Server, I had not installed it in years, last version I installed was 2000. This time it is the 2008, express (free) edition. It wants to install .net, fine with me ... but it wants two distinct versions ... WTF? Again, backward compatibility is a pain with .net. Can't they at least port all their code to the latest version? losers!

The other thing that strikes me, the installation for .net takes ages, using 100%, in a vm ... but I can run a double-stack SAP instance in a vm on my box (it is pretty heavy gear) ... On the dialog it says: Download finished, you may disconnect from the internet ... does it think I use a 56k modem?

Well, I will have a look at this thing anyway, everybody deserves a 512th chance, right?

Well, anyway, after installing powershell I could continue installation. But it failed with the following message:

TITLE: Microsoft SQL Server 2008 R2 Setup
------------------------------

The following error has occurred:

A network error occurred while attempting to read from the file: e:\b79ad030129e84bb93122e9bed672fb5\1033_ENU_LP\x86\setup\x86\sqlwriter.msi

The weird thing is, guess what, e: is a local drive.

Anyway, I was installing over the network, the original installation file resides on my linux samba server (drive z:) and I installed to my e: drive. I copied it over and started the installation again, which worked.

Installing the "SQL Server Management Studio" was weird, as the installer made me doubt what I was installing ... it looked so much like the database installer and even the link to install it read database, not Management Studio ... I do not quite know why I installed that, osql does the job just as well ... ;-)

I do need to get used to typing go, though ... which is a bit weird, because I used to be accustomed to this, but 5 years of Oracle use have made me become lazy, especially after select statements.

lundi 17 mai 2010

TNS-04413: A shared object was found in the subtree

I installed Oracle 11g on Linux, debian squeeze, last week and came across a weird error after having had to configure the sqlnet stuff. Oracle doesn't seem to be able to do that on debian-based systems, nor on Solaris ... so maybe all unices are affected. I don't know, I must be making a big mistake somewhere during installation ... ;-)

So, I thouht I had set everything up as it should be, but I had a problem in the sqlnet configuration, as the listener did not want to serve my database.

I started dbca to check if it could find the database and got several errors, that pointed me in the right direction ... ;-).

I figured it out in the end, I had this line:


(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
iso
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))


I had somehow gotten the listener port at the end of EXTPROC, don't ask me how that happened ... must have made a typo in vi. The weird thing is, that I found nothing on the interwebs about the error:


TNS-04413: A shared object was found in the subtree

So here is a blog entry about that ... ;-)

See below:

oracle@hpcarpenter:~$ lsnrctl start


LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 17-MAY-2010 14:57:07

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Starting /u00/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u00/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u00/app/oracle/diag/tnslsnr/hpcarpenter/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hpcarpenter.masalan)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 17-MAY-2010 14:57:09
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u00/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u00/app/oracle/diag/tnslsnr/hpcarpenter/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hpcarpenter.masalan)(PORT=1521)))
The listener supports no services
The command completed successfully
oracle@hpcarpenter:~$ dbca
Can't get a listener LISTENER Exception: oracle.net.config.ListenerException: TNS-04412: A problem reading or writing an address
caused by: oracle.net.config.SOExceptionConfig:
TNS-04413: A shared object was found in the subtree

samedi 15 mai 2010

SAP - Sybase

I also have a faible for Sybase, mainly because my wife worked there. Anyway, SAP just bought the company. I downloaded ASE last month and later had a sales chap on the phone (he called me to know how it was going), I asked if they supported SAP, and he sort of started to mumble something ... then said the next version might ... I thought there was something breeding ... here you go!

Microsoft, I think SAP is starting to show you something ... ;-) and Sybase will be more than happy to take its revenge!

Accenture, the suckerz

Ok, today I would like to talk about .... Accenture. I know somebody who works there, a project manager ... apparently he knows very little about alternatives to a Microsoft-only implementation (except for software not covered by MS).

I had a discussion with a lad in the pub the other night, who was telling me his company uses Oracle db's with SAP, they got Accenture in for some consultancy ... and now, they are switching to SQL Server, because Accenture only deals with that.

Morality, if you hire Accenture in, your datancenter will become mostly MS, who said putting all your eggs into one basket was a bad idea?

dimanche 2 mai 2010

.net

I refuse to use .net stuff, oh, I have given it a try, I ended up with three or four different versions of the runtime installed on one computer, because I thought backward-compatibility was something the developers had heard of ... silly me!

So now, on this new computer I just set up, I have already discarded 2 pieces of software that wanted the .net crap. I don't understand why anyone develops in that crap ... there is absolutely no cross-platform support (mono is a joke!), not even native XP support (which still is the #1 OS out there) .... and when it says it wants 1.1, then it means it ... 3.0, 2.0 or even 1.3 are not accepted, WTF? I mean you have similar issues with Java, like a program written for Java 1.2 might not work wth 1.6, it will "usually" work with 1.3, 1.4 and 1.5, though ...

iiiiBoycott that crap!!!!!

jeudi 1 avril 2010

Ubuntu cares?

I had a few issues with my ubuntu. After quite some time, I decided to investigate and found the following:

ls -la /bin/sh
lrwxrwxrwx 1 root root 4 2009-05-27 16:32 /bin/sh -> dash

To speed up boot time on ubuntu, which has never been an issue if you ask me, they replaced bash with dash as the default shell (sh). So now, /bin/sh is linked to /bin/dash.

They could have changed all their boot stuff to use dash instead of bash without breaking anybody's code, but hey, that would only be half the fun. Don't tell us that would be too much work, you had to convert all your scripts to be compatible with the new shell anyway. The dash [s]hell supports a subset of what bash does, apparently only POSIX-compliant stuff. So here we are again, I'm getting "-sh: typeset: not found", let and $RANDOM that do not work anymore among many things.

Read here for more info: https://wiki.ubuntu.com/DashAsBinSh