Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

Thursday, October 1, 2009

How to rename files recursively in Debian GNU/Linux 5.0 "lenny"

Recently I have mirrored some website to my local disk. I found that most pages were stored in files with ".php" extension. Those files were plain HTML, but my web browser has flatly refused to display them. Yes, I confess, I simply overlooked a very useful wget option - "--html-extension" :)

I didn't want to download everything again, so I decided to simply rename all *.php to *.html, and fix the links inside so they were pointing to renamed files. It proved to be not an easy task for a novice Linux user such as myself :)

The following command recursively replaces the extension ".php" to ".html", starting from the current directory:
find . -name *.php -type f -print0 | xargs -0 -I '{}' rename 's/\.php/\.html/' '{}'

Now fixing hyperlinks inside the web pages:
find . -name *.html -exec sed -i 's/\.php/\.html/' '{}' \;

That's it :)

Monday, September 28, 2009

Running auCDtect under Debian GNU/Linux 5.0 "lenny"

Tau Analyzer is able to detect whether the audio CD was created from studio-based recordings, or from some decompressed lossy audio format, such as MP3. In other words, Tau Analyzer allows to determine the "authenticity" of an audio CD.

There is only a Windows version of Tau Analyzer available. AuCDtect can be used in the Linux environment for the same purpose.

AuCDtect is a console program which uses the same algorithm as Tau Analyzer. In contrast to Tau Analyzer, which works with a CD drive directly, AuCDtect works with an audio CD image file stored in .wav format. AuCDtect expects the name of the image file as a command line argument.

To run under Debian GNU/Linux 5.0 "lenny", use AuCDtect version 0.8 (Linux x86). Tau Analyzer and AuCDtect for Windows are also available for download from this page.

Unpack the archive into any suitable directory:
abunakov@debian:~/work$ tar zxf ~/downloads/aucdtect-0.8.2.tgz

When you run auCDtect, it gives the following error message:
abunakov@debian:~/work$ ./aucdtect-0.8.2/auCDtect
./aucdtect-0.8.2/auCDtect: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

As follows from this error message, auCDtect could not find the libstdc++-libc6.2-2.so.3 shared library. This is an outdated version of The GNU Standard C++ Library. auCDtect is also incompatible with the version of the library which is shipped with Debian GNU/Linux 5.0 "lenny":
debian:/home/abunakov/work# ln -b -s libstdc++.so.6 /usr/lib/libstdc++-libc6.2-2.so.3
debian:/home/abunakov/work# ./aucdtect-0.8.2/auCDtect
auCDtect: CD records authenticity detector, version 0.8.2
Copyright (c) 2004 Oleg Berngardt. All rights reserved.
Copyright (c) 2004 Alexander Djourik. All rights reserved.
./aucdtect-0.8.2/auCDtect: symbol lookup error: ./aucdtect-0.8.2/auCDtect: undefined symbol: __builtin_new
debian:/home/abunakov/work# rm /usr/lib/libstdc++-libc6.2-2.so.3

Download the libstdc++2.10-glibc2.2_2.95.4-27_i386.deb package for Intel x86 platform from one of the mirrors listed on this page.

It is recommended to extract this package into the same directory where you unpacked auCDtect:
abunakov@debian:~/work$ dpkg -x ./libstdc++2.10-glibc2.2_2.95.4-27_i386.deb ./aucdtect-0.8.2

You must specify the path to libstdc++-libc6.2-2.so.3 in LD_LIBRARY_PATH environment variable. You can specify this path directly on the command line:
abunakov@debian:~/work$ LD_LIBRARY_PATH=./aucdtect-0.8.2/usr/lib ./aucdtect-0.8.2/auCDtect
auCDtect: CD records authenticity detector, version 0.8.2
Copyright (c) 2004 Oleg Berngardt. All rights reserved.
Copyright (c) 2004 Alexander Djourik. All rights reserved.
------------------------------------------------------------
Usage: auCDtect [commands/options] (track.wav|*.wav)
------------------------------------------------------------
commands:
------------------------------------------------------------
-- read data from stdin
-d summary conclusion for set of tracks
-v verbose mode
-h this help
------------------------------------------------------------
options:
------------------------------------------------------------
-mS detect mode S=[0..40], default 8
0 - slow and most accurate
40 - fast, but less accurate
------------------------------------------------------------
For more information please visit: http://www.true-audio.com

To avoid the hassle of having to define the LD_LIBRARY_PATH on the command line each time you want to run auCDtect, you can add a line like this:
export LD_LIBRARY_PATH=~/work/aucdtect-0.8.2/usr/lib

to your ~ /.bashrc file, and run auCDtect with a shorter command:
abunakov@debian:~/work$ ./aucdtect-0.8.2/auCDtect

Unfortunately, I could not fix the error, which auCDtect gives at the end of analysis:
------------------------------------------------------------
This track looks like CDDA with probability 100%


*** glibc detected *** ./aucdtect-0.8.2/auCDtect: double free or corruption (!prev): 0x08b78008 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb7e5c624]
/lib/i686/cmov/libc.so.6(cfree+0x96)[0xb7e5e826]
./aucdtect-0.8.2/auCDtect[0x8049741]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7e04455]
./aucdtect-0.8.2/auCDtect(__register_frame_info+0x45)[0x80489b1]

The reason is that libstdc++-libc6.2-2.so.3, which auCDtect uses, is incompatible with another standard library, libc.so.6, which is installed in the system. You could try to download and use the appropriate version of libc.so.6, but I decided not to do so, because for me, despite of errors, auCDtect does its job, and I'm pretty happy with the results.

By the way,  libstdc++-libc6.2-2.so.3 is just a symlink to another file, libstdc++-3-libc6.2-2-2.10.0.so.  So, if you decide to move this library to some other location, make sure you move both files.