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 />

Capitolo 12. Filtri, programmi e coman<strong>di</strong> esterni<br />

fi<br />

done<br />

echo $pre_file >> $TMP # TMP ora contiene la<br />

#+ lista COMPLETA e<br />

#+ aggiornata.<br />

# echo "subshell=$BASH_SUBSHELL"<br />

} # Le parentesi graffe sono necessarie per consentire a<br />

#+ "echo $pre_file >> $TMP" finale <strong>di</strong> rimanere nella stessa<br />

#+ subshell ( 1 ) assiema all’intero ciclo.<br />

RIT=$? # Recupera il co<strong>di</strong>ce <strong>di</strong> ritorno della pipe.<br />

[ "$RIT" -ne 0 ] && {<br />

echo "Recupero della lista fallito con co<strong>di</strong>ce $RET"<br />

exit $E_RETURN<br />

}<br />

echo "fatto"; echo<br />

# Download <strong>di</strong> rsync.<br />

scarica_file () {<br />

}<br />

echo "In download..."<br />

/bin/nice /usr/bin/rsync \<br />

$OPZ \<br />

--filter "merge,+/ $TMP" \<br />

--exclude ’*’ \<br />

$URL $DEST \<br />

| /usr/bin/tee $LOG<br />

RIT=$?<br />

# --filter merge,+/ è cruciale allo scopo.<br />

# + il mo<strong>di</strong>ficatore significa inclu<strong>di</strong> e / percorso assoluto.<br />

# Quin<strong>di</strong>, l’elenco or<strong>di</strong>nato presente in $TMP conterrà i nomi delle<br />

#+ <strong>di</strong>rectory in or<strong>di</strong>ne ascendente impedendo al successivo<br />

#+ --exclude ’*’ <strong>di</strong> mandare tutto in "corto circuito."<br />

echo "Fatto"<br />

rm -f $PID_FILE 2>/dev/null<br />

return $RIT<br />

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

# Main<br />

init<br />

controlla_pid<br />

imposta_intervallo<br />

crea_lista<br />

309

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

Saved successfully!

Ooh no, something went wrong!