• [^] # Re: en bash

    Posté par . En réponse au message et logique ?. Évalué à 2.

    Ok, j'avais même pas pensé car je me suis dis que c'était dur car je ne connais rien aux script mais pas forcement interesant quand on connais un peu. En tout cas voici les lignes pour recuperer l'adresse du réseau associé à un ip et le mask :

    mask=`ifconfig eth0|grep Masque|cut -d ':' -f4`
    echo $mask
    mask1=`ifconfig eth0|grep Masque|cut -d ':' -f4|cut -d '.' -f1`
    mask2=`ifconfig eth0|grep Masque|cut -d ':' -f4|cut -d '.' -f2`
    mask3=`ifconfig eth0|grep Masque|cut -d ':' -f4|cut -d '.' -f3`
    mask4=`ifconfig eth0|grep Masque|cut -d ':' -f4|cut -d '.' -f4`

    ip=`ifconfig eth0|grep Masque|cut -d ':' -f2|cut -d ' ' -f1`
    echo $ip
    ip1=`ifconfig eth0|grep Masque|cut -d ':' -f2|cut -d '.' -f1`
    ip2=`ifconfig eth0|grep Masque|cut -d ':' -f2|cut -d '.' -f2`
    ip3=`ifconfig eth0|grep Masque|cut -d ':' -f2|cut -d '.' -f3`
    ip4=`ifconfig eth0|grep Masque|cut -d ':' -f2|cut -d '.' -f4|cut -d ' ' -f1`

    ip_res=$[${mask1} & ${ip1}]"."$[${mask2} & ${ip2}]"."$[${mask3} & ${ip3}]"."$[${mask4} & ${ip4}]
    echo $ip_res