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.

E_NO_URLS=69 # No URLs passed to script.<br />

E_NO_SAVEFILE=70 # No save filename passed to script.<br />

E_USER_EXIT=71 # User decides to quit.<br />

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

# Basic default wget command we want to use.<br />

# This is the place to change it, if required.<br />

# NB: if using a proxy, set http_proxy = yourproxy in .wgetrc.<br />

# Otherwise delete --proxy=on, below.<br />

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

CommandA="wget -nc -c -t 5 --progress=bar --random-wait --proxy=on -r"<br />

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

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

# Set some other variables and explain them.<br />

pattern=" -A .jpg,.JPG,.jpeg,.JPEG,.gif,.GIF,.htm,.html,.shtml,.php"<br />

# wget’s option to only get certain types of file.<br />

# comment out if not using<br />

today=‘date +%F‘ # Used for a filename.<br />

home=$HOME # Set HOME to an internal variable.<br />

# In case some other path is used, change it here.<br />

depthDefault=3 # Set a sensible default recursion.<br />

Depth=$depthDefault # Otherwise user feedback doesn’t tie in properly.<br />

RefA="" # Set blank referring page.<br />

Flag="" # Default to not saving anything,<br />

#+ or whatever else might be wanted in future.<br />

lister="" # Used for passing a list of urls <strong>di</strong>rectly to wget.<br />

Woptions="" # Used for passing wget some options for itself.<br />

inFile="" # Used for the run function.<br />

newFile="" # Used for the run function.<br />

savePath="$home/w-save"<br />

Config="$home/.wgetter2rc"<br />

# This is where some variables can be stored,<br />

#+ if permanently changed from within the script.<br />

Cookie_List="$home/.cookielist"<br />

# So we know where the cookies are kept . . .<br />

cFlag="" # Part of the cookie file selection routine.<br />

# Define the options available. Easy to change letters here if needed.<br />

# These are the optional options; you don’t just wait to be asked.<br />

save=s # Save command instead of executing it.<br />

cook=c # Change cookie file for this session.<br />

help=h # Usage guide.<br />

list=l # Pass wget the -i option and URL list.<br />

runn=r # Run saved commands as an argument to the option.<br />

inpu=i # Run saved commands interactively.<br />

wopt=w # Allow to enter options to pass <strong>di</strong>rectly to wget.<br />

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

718

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

Saved successfully!

Ooh no, something went wrong!