Linux, programming, computers and life

November 16, 2008

proud eee owner :)

Filed under: life

Thanks to my fiance, I’m now Eee 1000 owner. It’s so cute, i like it a lot :) . The question, what Linux distributive should i install there?
I have Arch on my desktop, and i love it, but I’d like to get something ready for Eee out of the box. Currently, the best solution looks Ubuntu Eee, but i’ll probably look for more options.

, , ,

November 8, 2008

overflow in shell script

Filed under: CLI, programming, linux

Overflow in shell script… while it sounds strange, it actually happened to me :) . I have a script which does recoding of mp3 files in order to reduce bitrate and space those files take. I tried to be smart and first detect the bitrate in order to avoid redundant recoding. Well, my script actually worked for a long time, but then it refused to recode file with bitrate 256 ;) .
It was my fault of course. In order to determine the bitrate, i used the following ash function:
# function to determine bitrate:
# expects a file as parameter
determine_birate() {
    if [ -z “$1″ ]
    then
        return 0 # invalid
    fi
   
    if [[ “${MP3INFO}” == “” ]]
    then
        return 1 # invalid
    fi

    return `”${MP3INFO}” -p “%r” “$1″`
}

MP3INFO is an application i use in order to read mp3 files meta data. Well, when the bitrate was 256 i got 0 returned, i guess bash has some limit of 1 byte somewhere :) . My quick fix was (and now it works great):
# function to determine bitrate:
# expects a file as parameter
determine_birate() {
    if [ -z “$1″ ]
    then
        return 0 # invalid
    fi
   
    if [[ “${MP3INFO}” == “” ]]
    then
        return 1 # invalid
    fi

    echo `”${MP3INFO}” -p “%r” “$1″`
}
….
CURRENT_BITRATE=`determine_birate “$file”`

, , , ,

Get free blog up and running in minutes with Blogsome
Theme designed by Gary Rogers