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.

exit 0<br />

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

Esempio A-4. encryptedpw: upload a un sito ftp utilizzando una password criptata localmente<br />

#!/bin/bash<br />

# Esempio "ex72.sh" mo<strong>di</strong>ficato per l’uso <strong>di</strong> una password criptata.<br />

# Va notato che resta ancora piuttosto insicuro,<br />

#+ dal momento che la password deco<strong>di</strong>ficata viene inviata in chiaro.<br />

# Se necessario usate un programma come "ssh".<br />

E_ERR_ARG=65<br />

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

then<br />

echo "Utilizzo: ‘basename $0‘ nomefile"<br />

exit $E_ERR_ARG<br />

fi<br />

Nomeutente=ecobel # Va impostata al nome utente.<br />

pword=/home/ecobel/secret/password_encrypted.file<br />

# File contenente la password cifrata.<br />

Nomefile=‘basename $1‘ # Elimina il percorso dal nome del file<br />

Server="XXX" # Impostatele con i nomi effettivi del server<br />

Directory="YYY" #+ & della <strong>di</strong>rectory.<br />

Password=‘cruft

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

Saved successfully!

Ooh no, something went wrong!