/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

  • 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

  • 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

  • Fortschrittsbalken fuer cp und mv

    Vapier vom Gentoo Dev Team bietet in seiner Patchsammlung fuer die coreutils den 001_all_coreutils-gen-progress-bar.patch Patch an.

    Durch das einspielen des Patches erhalten wir einen tollen Fortschrittsbalken bei den Befehlen cp und mv:

    cp -g /mnt/etcbackup.zip ~/temp
    etcbackup.zip          |   1% |   175 MiB |   122 KiB/s | ETA 00:24.03

    Zu finden ist die ganze Patchsammlung hier:
    http://dev.gentoo.org/~vapier/dist/coreutils-6.9-patches-1.2.tar.bz2

    Was etwas unklar ist das Gentoo direkt beim Ebuild fuer die coreutils einige Patches verwendet jedoch gerade diesen loescht!

    hihi, doch glatt vergessen wo ich das gefunden habe:
    geekosphere.org

    Posted

    December 1, 2007

    Tags

    bash, linux

  • lftp upload, download limitieren

    Ich verwende zur Zeit fuer kleinere sftp/ftp Geschichten lftp. Nun wollte ich “schnell” den upload limitieren damit das Surfen nicht zur Qual wird hierfuer fuehrt man einfach in lftp folgendes aus:

    set limit-rate <download-rate>:<upload-rate>

    Posted

    November 30, 2007

    Tags

    bash, bsd, linux

« Previous Entries