Archivio

Posts Tagged ‘linux’

Minimalism

giugno 1, 2013 Commenti disabilitati

Recentemente ho tenuto una lezione al Polito su minimalism.
Gli argomenti variano dallo shell scripting alle regular expression finendo poi su come utilizzare strumenti alternativi a quelli normalmente grafici, facendo tutto da terminale.

Parlo di:
– automatizzazione pc
– shell scripting
– xterm basic config
– screen – config e utilizzo
– shell scripting: howto & esempi
– vim – config, utilizzo e comandi
– awk – uso semplice e complesso
– sed – strumenti ed esempi
– regular expression: spiegazione semplice e trucchetti
– fluxbox: configurazione base e links
– filosofia KISS: minimalismo come scelta di vita e di lavoro
– una marea di link per approfondire e non solo

Se volete dare un occhiata alle slide (testuali) che ho fatto potete installarvi il programma tpp

e quindi scaricare slide ed esempi da qui:
https://github.com/opensamba/minimalism

[tpp slide]: https://github.com/opensamba/minimalism/blob/master/minimalism_slide.tpp
[examples]: https://github.com/opensamba/minimalism/tree/master/example

bye

bash scripting: change delim using for

gennaio 7, 2013 Commenti disabilitati

Usually when I write shell script I prefer to use the statement “for”.
But there’s a problem: by default the ‘for’ get every single word.

That’s because if not specified the ‘for’ use as delimiter the space character (” “).
So, if I want to work with several word in a single iteration i need to change the delimiter.

That’s easy!
To change the delimiter you just need to change the variable IFS.

Let’s see some code:


LOGFILE=/var/log/mylogfile.log
IFS=";"                              # change delimiter in ";" (magic)
EXCEPTIONS="timeout;java.somerror;a lot of errors"    # my exception 
for word in $EXCEPTIONS;do
    echo -n "Check Exception: \"$word\" ..."         # escape "
    N=$(grep -ic $word $LOGFILE)                     # check log
    if [ $N -gt 0 ];then                             # if found
        echo -e "\nWARNING: Found $N exception:\"$word\"" # print 
    else
        echo "None"                                  # else no
    fi
done

output:


> Check Exception: "timeout"...None
> Check Exception: "java.somerror"...None
> Check Exception: "a lot of errors"...
WARNING: Found 3 exception "a lot of errors"

That’s an easy way to use the ‘for’ statement even if usually cant and so you can write good code.
enjoy 🙂

Categorie:linux Tag:, , , , , , ,

spamc/spamd su ubuntu

dicembre 14, 2012 Commenti disabilitati

Ho configurato mutt + spamassassin e vorrei che spamassassin si attivasse da solo al boot, per farlo non ho trovato molto HOWTO in giro, quindi ho deciso di farne uno io.

Prima di tutto bisogna installare spamc, il client di spamassassin che ci permette di capire quando una mail è spam o no.

1. Installare spamc.

sudo aptitude install spamc

2. Quindi modifico /etc/default/spamassassin per abilitare al boot l’avvio di spamd. basta cambaiare nel file le seguenti info:

ENABLED=1

Per far aggiornare spamassassin automaticamente e farlo diventare piu’ esperto bisogna modificare anche questa variabile al fondo del file:

CRON=1

(in questo modo dovrebbe fare un sa-update ogni notte)

3. facciamo parire spamd:
Quote:

sudo /etc/init.d/spamassassin start

4. modificare il file ~/.procmailrc così da mandare tutto le mail marcate come spam nella cartella ~/spam/
Quote:

:0fw:spamassassin.lock
| /usr/bin/spamc
* ^X-Spam-Status: Yes
spam/

e con questo dovrebbe essere tutto.

This information was collected from the following places:
http://www.howtoforge.com/forums/showthread.php?t=28534
http://samat.org/pages/speeding-up-s…nd-ubuntu.html
http://spamassassin.apache.org/

Installazione Ubuntu

dicembre 5, 2012 Commenti disabilitati

Ieri ho fatto una bella lezione al Poli e lascio qui un ricordo delle slide dell’Installazione Ubuntu

Categorie:varie Tag:, , ,

Bacula talk

novembre 23, 2012 Commenti disabilitati

Mercoledì  21/11 ho tenuto al Politecnico di Torino un talk su Bacula al Poli.
Qui ci sono le Slide che ho fatto : Bacula: the leading Opensource Backup Solution
Aggiungo per info che le slide sono prese e modificate direttmente dal sito Bacula.org > Presentation

enjoy

Categorie:linux Tag:, , ,