11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

echo "Searching for $IPADDR in whois.registro.br"<br />

whois -h whois.registro.br "$IPADDR" >> $OUTFILE<br />

fi<br />

RIPEquery() {<br />

echo "Searching for $IPADDR in whois.ripe.net"<br />

whois -h whois.ripe.net "$IPADDR" > $OUTFILE<br />

}<br />

# Initialize a few variables.<br />

# * slash8 is the most significant octet<br />

# * slash16 consists of the two most significant octets<br />

# * octet2 is the second most significant octet<br />

Appen<strong>di</strong>ce A. Script aggiuntivi<br />

slash8=‘echo $IPADDR | cut -d. -f 1‘<br />

if [ -z "$slash8" ] # Yet another sanity check.<br />

then<br />

echo "Undefined error!"<br />

exit $E_UNDEF<br />

fi<br />

slash16=‘echo $IPADDR | cut -d. -f 1-2‘<br />

# ^ Period specified as ’cut" delimiter.<br />

if [ -z "$slash16" ]<br />

then<br />

echo "Undefined error!"<br />

exit $E_UNDEF<br />

fi<br />

octet2=‘echo $slash16 | cut -d. -f 2‘<br />

if [ -z "$octet2" ]<br />

then<br />

echo "Undefined error!"<br />

exit $E_UNDEF<br />

fi<br />

# Check for various odds and ends of reserved space.<br />

# There is no point in querying for those addresses.<br />

if [ $slash8 == 0 ]; then<br />

echo $IPADDR is ’"This Network"’ space\; Not querying<br />

elif [ $slash8 == 10 ]; then<br />

echo $IPADDR is RFC1918 space\; Not querying<br />

elif [ $slash8 == 14 ]; then<br />

echo $IPADDR is ’"Public Data Network"’ space\; Not querying<br />

elif [ $slash8 == 127 ]; then<br />

echo $IPADDR is loopback space\; Not querying<br />

elif [ $slash16 == 169.254 ]; then<br />

echo $IPADDR is link-local space\; Not querying<br />

elif [ $slash8 == 172 ] && [ $octet2 -ge 16 ] && [ $octet2 -le 31 ];then<br />

715

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!