Sunday, May 22, 2005

Where is the kernel config in Fedora Core 3

I recently had a question as to where the .config file was in Fedora Core 3 as to allow me to attempt to enable a Marvel Yukon 88E8050 PCI Express Gigabit Ethernet Controller. I subsequently found that the config is stored in /boot rather that /proc/.config.gz.

The reasoning they choose to employ this approach was due to the memory usage associated with storing the configuration within /proc.

Friday, May 20, 2005

Bash shell scripting ( [[ ]] conditions)

A question was asked recently what is the difference between "[ ]" and "[[ ]]" when used in a conditional statement in bash shell scripting.

As I found making use of the [ ] provides what is known as a "simple" test.

if [ "one" = "one" ]; then
echo "one is one"
fi

Where as the [[ ]] provides for a compound test in addition to having conditional operators that are more typical in other languages.

if [[ "one" == "one" && "two" == "two" ]]; then
echo "Normality restored"
fi

Operators like && || and the like are not possible in the simple test

Bash shell scripting (string testing)

The question was recently asked how are you supposed to correctly test for a string in a conditional statement in shell script?

Contrary to my initial suspicion the operators:

-eq
-ne
-gt
...

Are to be used for integer comparison and as a result result vary wildly.

Making correct operators used for string comparison I found are:

=
!=

Bash shell scripting (string testing)

The question was recently asked how are you supposed to correctly test for a string in a conditional statement in shell script?

Contrary to my initial suspicion the operators:

-eq
-ne
-gt
...

Are to be used for integer comparison and as a result result vary wildly.

Making correct operators used for string comparison I found are:

=
!=

Saturday, May 14, 2005

How do you convert a bunch of wave files into mp3 using lame on linux

I had a bunch of files with names like:
The Last Stand of the Tin Can Sailors - D07T01.wav

Using a simple for loop in shell would not suffice. I found that the readdir() function in perl would not expand (breakup) the filename like the shell would so I devised a simple little perl script that would be run under the directory where you the wave files.

#!/usr/bin/perl
endir(DH,".");
@files = readdir(DH);
$lame = "the_path_to_lame";
foreach $file (@files) {
next if($file eq "." || $file eq "..");
$mp3 = $file;
$mp3 =~ s/(.*)\.wav/$1/;
system("$lame --preset cbr 128 \"$file\" \"$mp3.mp3\" ");
}

Monday, May 09, 2005

Query Design creating where clauses

Doing a typical select statement select * from jobs where vulnCount = 5 doesn't seem to be possible with OpenOffice. To construct a where clause using the Query Design you need to make use of "(" ")" to encapsulate the where condition.

You're query would look like:
SELECT Field from DSN.dbo.Table Table WHERE (field='condition')

Friday, May 06, 2005

Doing CIDR mask calculations in perl

I recently had a need for an application that would allow a user to specify a host range and would require the user to make use of CIDR mask notation.

A quick look on search.cpan.org locates a number of options. I made use of http://search.cpan.org/~dougw/Net-CIDR-Lite-0.15/Lite.pm and it able to meet the requirements quite nicely.

Extracting a single directory with tar

Finally had a need to make use of the tar option to extract a single directory from a tarball. After kicking the man page around I came up with:

tar -xvf archive.tar "root/Windows 2000 Professional/"