/home/drscream

  • home
  • blog
  • gallery
  • about
  • bash variable set default value

    Yeaaa :-) Yesterday i’ve found a nice way to set an default value for bash variables.
    I use this way if parameter 1 isn’t assigned by the user. Here a small example:

    ip=${1-'10.1.1.1'}

    If $1 isn’t assigned by the user the default 10.1.1.1 is set as value of $ip.

    Posted

    March 29, 2008

    Tags

    bash, linux

  • Mutt move mails by pattern

    In mutt it isn’t so easy to move mails by pattern because the best solution is to move mails not in the mail client but with procmail or mailfilter. Here is a solution that works also in mutt:

    Tag all mails by specific pattern:
    Limit the mails that are displayed.

    L


    Tag messages matching a pattern.

    T


    Move all taged mails to destination:

    s =INBOX.dest.here

    Posted

    March 25, 2008

    Tags

    linux, mutt

  • Find easy empty directorys with ‘find’

    With find you can everything but you must know it :)

    find . -type d -empty

    [drscream@havanna] ~/Pictures/upload
     % find . -type d -empty
    ./Artwork/html/thumb
    ./Artwork/Photography/html/thumb
    ./html/thumb
    

    Posted

    March 2, 2008

    Tags

    bash, linux

  • How to find out your Tcl version

    It’s so easy, i’ve only searched a day long for that easy result:-P

    [drscream@havanna] ~
     % tclsh
    % puts $tcl_version
    8.4
    

    Posted

    March 1, 2008

    Tags

    bash, linux, macosx, tcl

  • Router, check the internet connection

    Currently i’ve some problems with my router. The reconnect only work sometimes… . So i’ve started to write a small bash script, to check that connection. The script run every hour and start a reconnection if no pppoe connection is available.

    
    #!/bin/bash
    #--------------------------------------------------------------------
    # $Id: checkIConnect,v 0.1 2008/02/11 17:17:26 drscream Exp $
    # Copyright 2008 Frubar Network (drscream@frubar.net)
    #--------------------------------------------------------------------
    
    ##
    ## main
    ##
    errors=0
    ns_ip=$(cat /etc/resolv.conf | sed 's/nameserver //g' | head -n 1)
    
    ## device check
    $(/sbin/ip a s dev ppp0 > /dev/null 2>&1)
    if [ $? -gt 0 ]; then
            echo "ERROR: Device not found!"
            let errors=$errors+1
    fi
    
    ## nameserver, ping check
    $(ping -c 4 $ns_ip > /dev/null 2>&1)
    if [ $? -gt 0 ]; then
            echo "ERROR: Ping doesn't work!"
            let errors=$errors+1
    fi
    
    echo "Code: $errors"
    
    if [ $errors -gt 0 ]; then
            echo "INFO: reconnect internet"
            /opt/fruky/bin/pppoe-restart
    fi
    

    Posted

    February 11, 2008

    Tags

    bash, linux

  • Bash, get the last day of the month

    Easy way to get the last day is to look if the next day is the first of the month. Now here are a small bash script thats show you the functionality:

    if [ $(date -d tomorrow +%d) -eq 1 ]; then
        echo "OK: last day of the month"
    else
        echo "NOK: not the last day of the month"
    fi
    

    Posted

    January 27, 2008

    Tags

    bash, linux

  • Argument list too long

    Wer kennt es nicht, gerade wenn man viele Datein loeschen moechte:

    Argument list too long.

    Ein einfacher “workaround” ist das verwenden von xargs:

    ls | xargs rm

    ( Vielen Dank an adminlife.net )

    Posted

    January 25, 2008

    Tags

    bash, linux

  • The UNIX Wizard …

    just found by Flickr:

    unix wizard

    The picture is under the creative commons license and the full sized picture can be downloaded here.

    Posted

    January 24, 2008

    Tags

    drawing, linux

  • vim dynamic fileheader

    I’ve currently programming some small bash scripts and I would use my default Frubar fileheader for every script:

    "--------------------------------------------------------------------
    " $Id: vimrc.header,v 0.1 2008/01/23 16:05:22 drscream Exp $
    " Copyright 2008 Frubar Network (drscream@frubar.net)
    "--------------------------------------------------------------------
    

    At this point i’ve written a small vimrc file, thats allows me to insert the header by typing ,fh. The vimrc.header file can be found here!

    To use this script insert the following in your ~/.vimrc file:

    " Source vimrc.header file, code header function
    let VIM_HEADER=expand("~/.vim/vimrc.header")
    if filereadable(VIM_HEADER)
            exe "source " VIM_HEADER
    endif
    

    Posted

    January 23, 2008

    Tags

    bash, linux, vim

  • linux dot files

    Now i’ve created a small subdomain for some interesting linux (and other system) dot files:
    dot.cyber-tec.org

    I hope someone need the stuff ;-)

    Posted

    January 7, 2008

    Tags

    bash, bsd, linux, vim

« Previous Entries