dee’s blog

expressions of my experience

About Me

    I live in Molfetta BA, Italy.
    I study computer science at Bari.
    I have more friend and a beautiful girlfriend.
    I like play football and fight to kick boxing.
    I love my grandmother's lasagna.

    ArchLinux User
    Dario `dax` Vilardi
    Public Key @ www.deelab.org/dax.asc
    7A94 51B8 9E37 8518 D71D 1C72 6272 6C18 27F1 81B0

    sticker-arch

Archive for the ‘scripting’ Category

March 8, 2008

myminstat.sh

uno scriptino utile su cui sto lavorando nel tempo libero.

codice:
#!/bin/bash
#v1=$(uptime | awk '{print "uptime: "$3}')
v1=$((`cut -f1 -d' ' /proc/uptime | cut -f1 -d.` / 60))
v2=$(cat /proc/net/dev | grep eth0 | tr ":" " " | awk '{ print "download: " $2/1024/1024 " MB, upload: " $10/1024/1024 " MB"}')
echo uptime: $v1 mins, $v2.

#!/bin/bash
v1=$((`cut -f1 -d’ ‘ /proc/uptime | cut -f1 -d.` / 60))
v2=$(echo “scale=2;$(cat /proc/net/dev | grep eth0 | tr “:” ” ” | awk ‘{ print $2 }’)/1024/1024″ |bc)
v3=$(echo “scale=2;$(cat /proc/net/dev | grep eth0 | tr “:” ” ” | awk ‘{ print $10 }’)/1024/1024″ |bc)
echo uptime: $v1 mins, downloads: $v2 MB, uploads: $v3 MB.

output:
$ sh myminstat.sh
uptime: 151 mins, download: 88.5834 MB, upload: 2112.35 MB.

uptime: 947 mins, downloads: 177.64 MB, uploads: 886.35 MB.

TODO:
1) approssimazione a due cifre dopo la virgola;
2) loggin su file;
3) statistiche;
4) parametrizzazione:
default: current tripla valori;
-x: differenza tra current e ultima tripla di valori presa;
-y: differenza tra current e prima tripla valori presa;
-m: media sull’intero log delle triple di valori prese.

February 22, 2008

perl: ln-s url redirector

Tonight was a sleepless night and i was reading perl scripts.
this one redirect url with one shorter, it was ln-s.net, my fav <3
script was almost usefull, just a weak: it use *always* a page :-/
not to bad, i have edited it using ARGV parameter:
die "Usage: ln-s.pl $url" if $#ARGV > 0 && $#ARGV < -1;
$url = $ARGV[0];

this lines instead of
$url = 'http://web.morons.org/article.jsp?sectionid=1&id=1';

this is a nopaste of my script.
this is how it work:
$ perl ln-s.pl http://www.deelab.org/
status: 200
message: http://ln-s.net/1_w$

greetings :)