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.

Esempio A-29. Rendere wget più semplice da usare<br />

#!/bin/bash<br />

# wgetter2.bash<br />

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

# Author: Little Monster [monster@monstruum.co.uk]<br />

# ==> Used in ABS Guide with permission of script author.<br />

# ==> This script still needs debugging and fixups (exercise for reader).<br />

# ==> It could also use some ad<strong>di</strong>tional e<strong>di</strong>ting in the comments.<br />

# This is wgetter2 --<br />

#+ a <strong>Bash</strong> script to make wget a bit more friendly, and save typing.<br />

# Carefully crafted by Little Monster.<br />

# More or less complete on 02/02/2005.<br />

# If you think this script can be improved,<br />

#+ email me at: monster@monstruum.co.uk<br />

# ==> and cc: to the author of the ABS Guide, please.<br />

# This script is licenced under the GPL.<br />

# You are free to copy, alter and re-use it,<br />

#+ but please don’t try to claim you wrote it.<br />

# Log your changes here instead.<br />

# =======================================================================<br />

# changelog:<br />

# 07/02/2005. Fixups by Little Monster.<br />

# 02/02/2005. Minor ad<strong>di</strong>tions by Little Monster.<br />

# (See after # +++++++++++ )<br />

# 29/01/2005. Minor stylistic e<strong>di</strong>ts and cleanups by author of ABS Guide.<br />

# Added exit error codes.<br />

# 22/11/2004. Finished initial version of second version of wgetter:<br />

# wgetter2 is born.<br />

# 01/12/2004. Changed ’runn’ function so it can be run 2 ways --<br />

# either ask for a file name or have one input on the CL.<br />

# 01/12/2004. Made sensible handling of no URL’s given.<br />

# 01/12/2004. Made loop of main options, so you don’t<br />

# have to keep calling wgetter 2 all the time.<br />

# Runs as a session instead.<br />

# 01/12/2004. Added looping to ’runn’ function.<br />

# Simplified and improved.<br />

# 01/12/2004. Added state to recursion setting.<br />

# Enables re-use of previous value.<br />

# 05/12/2004. Mo<strong>di</strong>fied the file detection routine in the ’runn’ function<br />

# so it’s not fooled by empty values, and is cleaner.<br />

# 01/02/2004. Added cookie fin<strong>di</strong>ng routine from later version (which<br />

# isn’t ready yet), so as not to have hard-coded paths.<br />

# =======================================================================<br />

# Error codes for abnormal exit.<br />

E_USAGE=67 # Usage message, then quit.<br />

E_NO_OPTS=68 # No command-line args entered.<br />

717

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

Saved successfully!

Ooh no, something went wrong!