rulururu

post Unzip or Unrar many files at once

March 22nd, 2008

Filed under: Linux — Kai @ 4:03 pm

If you’ve got a directory with dozens of zipped or rar’d files, you can run a single command to unzip them all in one step, thanks to the power of the bash shell.

For this task, we’ll use bash’s for loop command structure. Replace var with a variable name, and list with either a command that outputs a list or an explicit list.

for <var> in <list>
do
  command $<var>;
done

You can run it on a single line with this syntax instead:

for <var> in <list>;do command $<var>;done

So if you want to unrar a list of files, you could use this command. You don’t necessarily need the quotes, but it helps when the filenames have spaces or something like that in them.

for f in *.rar;do unrar e "$f";done

If you wanted to use 7zip to extract a list of files:

for f in *.001;do 7z e "$f";done

Or if you wanted to unzip a list of files:

for f in *.zip;do unzip "$f";done

You could even chain commands together if you wanted to. For instance, if all your zip files contained .txt files and you wanted to unzip them and then move the unzipped files to another directory:

for f in *.zip;do unzip "$f";done; for f in *.txt;do mv "$f" /myfolder/;done

The bash shell is just so incredibly powerfull, this doesn’t even tap the power, but it should give you a good idea of what is possible.

post Realtime Apache monitoring with apachetop

March 17th, 2008

Filed under: Internet, Linux, Software — Kai @ 5:10 pm

Using apachetop you can watch every request on your apache webserver smiliar to watching progresses with top at your local system.

It works by processing the logfiles found in /var/log/apache.

By default apachetop will use your log in /var/log/apache/access.log, but you can add a -f flag to the command and point it to wherever your apache log really is if you moved it.

apachetop -f var/log/httpd-access.log

In the header of the output apachetop generates some small statistics about number of requests, the transfered data and the returned status codes since apachetop was started and for also for the last 30 seconds.
Additionally the last few requests are listed. Press “d” to switch from requested urls to refferrers or client IPs.

Man Page:
apachetop(1)
Project Page:
Apachetop - Top-like display of Apache logs

post Rock yourself to sleep

February 25th, 2008

Filed under: Linux, Music — Kai @ 7:00 am

When going to bed I usually listen to some good melotic rock rhythms until falling asleep. Most times my computer is supposed to play music for half an hour and then switch off.
I simply shutdown after thirty minutes:

shutdown -h 30

But what can you do if you just wanna stop the music after half an hour but the pc should keep on working all night. That’s what I asked myself yesterday night. I sorted out the problem by using DCOP which stands for Desktop COmmunication Protocol.

Essentially, DCOP is a “remote control” system, which allows an application or a script to be controlled from outside. I use this software for years for my remote control with LIRC (Linux Infrared Remote Control) to gives impulses to Amarok player.

The model is simple. Each application using DCOP is a client. They communicate to each other through a DCOP server, which functions like a traffic director, dispatching messages/calls to the proper destinations. All clients are peers of each other.

For example you can tell xmms to pause playing music:

dcop xmms player pause

To wait for thirty minutes and then stop Amarok is as simple as the previous example:

sleep 30m; dcop amarok player stop

If you have further interest in DCOP here’s a simple guide howto implement a DCOP interface yourself:
Creating a DCOP Interface

It’s interesting to know that in modern KDE systems, every KDE application supports a basic set of DCOP interfaces, even if the programmer of the application did not explicitly code in such support.

KDE API Reference:
The DCOP Desktop COmmunication Protocol library

post Photoshop soon available on Linux?

February 20th, 2008

Filed under: Linux, Software — Kai @ 10:27 pm

According to a survey implemented by Novell Adobe Photoshop is the most missed software product for Linux users. I can definitely approve that ’cause I don’t often need Windows but for Photoshop CS I have to switch on my Windows PC.

Indeed Gimp is a great graphics editor but not sufficiant. Maybe it has the same features and you can do almost the same stuff with it like with Photoshop but if you’ve worked for years with Photoshop, like I did, you’re kinda familiar with its usage. I utterly would spend more time on looking for a similar function in Gimp than just using Photoshop on Windows.

Google is funding work to ensure the Windows version of Adobe Systems’ Photoshop and other Creative Suite software can run on Linux computers. For working efficiently on that project Google hired developers from Codeweavers. The very well-known open-source project Wine is produced and supported by Codeweavers.

Some time ago also Adobe itself tried to make a running Linux solution of Photoshop - but unfortunately without success. According to my opinion it’s great that specialist make sure that Photoshop will run perfectly under wine in future.

Codeweavers

In marked contrast to other people on the Internet I can’t find something bad concerning the fact Google will fund for improve the Wine/Photoshop combination. Althougth it’s no act of charity by Google - they’re just trying to invest into the right projects. From my point of view projects being open source getting supported by Google is rather good than bad.

post Making a audio-cd the easy way

February 2nd, 2008

Filed under: Linux, Music — Kai @ 4:35 pm

Almost everybody know that situation only too well - you quickly have to burn an audio cd (e.g. for a party) and need all the tracks on cover.

I used to burn the cd with K3b or Brasero and then made a screenshot which I quickly edited to a fitting size with gimp and finally printed it.

Yesterday I found a better way when coming accross cdlabelgen, a great console-tool for making printable cd covers.

Usage can for example be:

cdlabelgen -c "Led Zeppelin" -s "Mothership" -o cover.ps

with parameter -f you can point to a file containing the tracknames.

cdlabelgen -c "Led Zeppelin" -s "Mothership" -f tracklist.txt -o cover.ps

I generate this file with a really short python script which I do pipe and writing the stream into a textfile:

ls -l | ./tracklist.py > tracklist.txt

#!/usr/bin/env python
from fileinput import input
import re
for line in input():
        s = line.find("- ")
        if s >= 0:
                line = line[s+2:line.find(".")]
                print line

Combination of all this to a small bash script gives you a great solution that saves a lot of time:

  • Generate tracklist
  • Get cd-title
  • Generate printable cover (postscript file)
  • Convert mp3 files to wav
  • Burn tracks using e.g. cdrecord

The script might look similar to this:

#!/bin/sh

#get title folder name
title=`${1} | awk 'BEGIN {FS="/"} {print $NF}'`
#generate list
ls -l ${1} | ./listfiles.py > tmp.txt
#generate label
cdlabelgen -c "`echo $title`"  -f ./tmp.txt -o ~/Desktop/label.ps
#delete list
rm tmp.txt
#convert mp3 to wav and burn
for i in *.mp3; do mpg123 -v -w "${i%mp3}wav" "$i"; done
cdrecord -dev=ATA:1,0,0 -eject speed=4 -pad -audio *.wav

If your printer is able to print postcript you can print directly like this:

cdlabelgen <args> | lpr -P<printername> -o Resolution=None -o PageSize=A4

You can add much more to your cover like images, date, etc. just have a look at the manpage.

post ext4 is on the rise

January 30th, 2008

Filed under: Linux — Kai @ 6:09 pm

tuxJust after Linus Torvalds has released Linux 2.6.24 kernel the development on 2.6.25 has started. With 2.6.25 lots of changes concerning ext4 filesystem are suggested.

The ext4 development ist not yet finished (it comes with the 2.6.19 kernel) - that’s the reason why Theodore Ts’o (tytso), leading developer on ext4, discourages from the usage in this early state for productive use. Nevertheless some distros soon will activate it in the kernel options. That’s why the developers of ext4 are going to implement new mount options to reveal that the filesystem is not ready for productive use but for test runs.

The major question is what the advantages of ext4 are.

  • Bigger data can be stored:
    Volumes up to 1024 petabytes (equiv. to 1,000,000 terabytes) are supported. With ext3 just 32 terabytes are possible.
  • Multiblock allocation:
    Addressing of data can be done with so-called extents, it merges data into blocks. This reduces time of access greatly. Moreover it’s more robust concerning hard disc crashes.
  • Number of subfolders increases:
    In comparison to ext3 it can store more subfolders (ext3 can hold 32,768 subdirs). This number will be broken with ext4.
  • More precise timestamps:
    Timestamps are more precise - they’d be set in nanoseconds.
  • Usage of checksums:
    A great feature will be that checksumming is used for journaling.

Besides those main features they still have some more features up their sleeve (e.g. increase the allowed filesize, online defragmentation, …).

I think those are great features that gives us lots of new possibilites - but some of them are not yet relevant (like 1024 petabytes storage). I’m really anxious how fast time will come when we think in those dimension of quantity.

Mounting ext4 can be done just the common way:

mount -t ext4dev -o extents /dev/sdc1 /mnt/test

It’s not necessary to convert ext3 partitions for the usage of ext4, they can be used by activating ext4 in the kernel.

If you don’t have a filesystem large enough and want to test 64bit feature, there is a script that creates a sparse file to simulate a large device (See explanation by Stephen Tweedie).
An other script is used to remove this sparse (./sparse_remove $map_name).

Ext4 is mostly based on parts of ext3 – similar to ext3 which is mainly based on ext2. Kernel developers think about deleting ext3 from the kernel source ’cause ext4 can manage ext3 perfectly and it would save affort to care for two sources the ext3 and ext4 one.

In the end some performace facts about ext4:
First benchmarks of the ext4 file system

ruldrurd
« Previous PageNext Page »
Powered by WordPress, Content and Design by Kai Bellmann
Entries (RSS) and Comments (RSS)