Just another problem

Win7: Access Point Discovery

Posted in tech by Adriano on 10/06/2011

Discover access points using the format below:

netsh wlan show networks mode=bssid

Anúncios

Bash: Mask Converter

Posted in tech by Adriano on 07/06/2011

Mostra o número de bits de uma máscara IP. Exemplo: 255.255.255.192 -> 26

#!/bin/bash
total_bits=0
for octet in `echo $1|awk -F. ' {print $1 " " $2 " " $3 " " $4}'`
do
    result=0
    mask=255
    num_bits=8
    while [ $mask -ge 0 ]
    do
        if [ $octet -eq $mask ]
        then
            break
        fi
        result=$(( $mask << 1 ))
        mask=$(( $result & 255 ))
        let num_bits=num_bits-1
    done
    let total_bits=total_bits+$num_bits
done
echo "$total_bits"