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.

if [ "$?" -eq $SUCCESSO ]<br />

then<br />

echo "È stato premuto il tasto Freccia-su."<br />

exit $SUCCESSO<br />

fi<br />

echo -n "$tasto" | grep "$frecciagiù"<br />

if [ "$?" -eq $SUCCESSO ]<br />

then<br />

echo "È stato premuto il tasto Freccia-giù."<br />

exit $SUCCESSO<br />

fi<br />

echo -n "$tasto" | grep "$frecciadestra"<br />

if [ "$?" -eq $SUCCESSO ]<br />

then<br />

echo "È stato premuto il tasto Freccia-destra."<br />

exit $SUCCESSO<br />

fi<br />

echo -n "$tasto" | grep "$frecciasinistra"<br />

if [ "$?" -eq $SUCCESSO ]<br />

then<br />

echo "È stato premuto il tasto Freccia-sinistra."<br />

exit $SUCCESSO<br />

fi<br />

echo -n "$tasto" | grep "$ins"<br />

if [ "$?" -eq $SUCCESSO ]<br />

then<br />

echo "È stato premuto il tasto \"Ins\"."<br />

exit $SUCCESSO<br />

fi<br />

echo -n "$tasto" | grep "$canc"<br />

if [ "$?" -eq $SUCCESSO ]<br />

then<br />

echo "È stato premuto il tasto \"Canc\"."<br />

exit $SUCCESSO<br />

fi<br />

echo " È stato premuto un altro tasto."<br />

exit $ALTRO<br />

Capitolo 11. Coman<strong>di</strong> interni e builtin<br />

# Esercizi:<br />

# --------<br />

# 1) Semplificate lo script trasformando le verifiche multiple "if" in un<br />

# costrutto ’case’.<br />

# 2) Aggiungete il rilevamento dei tasti "Home", "Fine", "PgUp" e "PgDn".<br />

# N.d.T. Attenzione! I co<strong>di</strong>ci dei tasti in<strong>di</strong>cati all’inizio potrebbero non<br />

196

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

Saved successfully!

Ooh no, something went wrong!