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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Capitolo 27. /dev e /proc<br />

bash$ cat /proc/partitions<br />

major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq<br />

3 0 3007872 hda 4472 22260 114520 94240 3551 18703 50384 549710 0 111550 644030<br />

3 1 52416 hda1 27 395 844 960 4 2 14 180 0 800 1140<br />

3 2 1 hda2 0 0 0 0 0 0 0 0 0 0 0<br />

3 4 165280 hda4 10 0 20 210 0 0 0 0 0 210 210<br />

...<br />

bash$ cat /proc/loadavg<br />

0.13 0.42 0.27 2/44 1119<br />

bash$ cat /proc/apm<br />

1.16 1.2 0x03 0x01 0xff 0x80 -1% -1 ?<br />

Gli script <strong>di</strong> shell possono ricavare dati da alcuni dei file presenti in /proc. 5<br />

FS=iso # Il supporto per il filesystem ISO è<br />

#+ abilitato nel kernel?<br />

grep $FS /proc/filesystems # iso9660<br />

versione_kernel=$( awk ’{ print $3 }’ /proc/version )<br />

CPU=$( awk ’/model name/ {print $4}’ < /proc/cpuinfo )<br />

if [ $CPU = Pentium ]<br />

then<br />

esegui_dei_coman<strong>di</strong><br />

...<br />

else<br />

esegui_altri_coman<strong>di</strong><br />

...<br />

fi<br />

506

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

Saved successfully!

Ooh no, something went wrong!