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

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

echo "Welcome to wgetter. This is a front end to wget."<br />

echo "It will always run wget with these options:"<br />

echo "$CommandA"<br />

echo "and the pattern to match: $pattern (which you can change at the top of this script<br />

echo "It will also ask you for recursion depth, and if you want to use a referring page.<br />

echo "Wgetter accepts the following options:"<br />

echo ""<br />

echo "-$help : Display this help."<br />

echo "-$save : Save the command to a file $savePath/wget-($today) instead of running it.<br />

echo "-$runn : Run saved wget commands instead of starting a new one --"<br />

echo "Enter filename as argument to this option."<br />

echo "-$inpu : Run saved wget commands interactively --"<br />

echo "The script will ask you for the filename."<br />

echo "-$cook : Change the cookies file for this session."<br />

echo "-$list : Tell wget to use URL’s from a list instead of from the command line."<br />

echo "-$wopt : Pass any other options <strong>di</strong>rect to wget."<br />

echo ""<br />

echo "See the wget man page for ad<strong>di</strong>tional options you can pass to wget."<br />

echo ""<br />

exit $E_USAGE # End here. Don’t process anything else.<br />

list_func() # Gives the user the option to use the -i option to wget,<br />

#+ and a list of URLs.<br />

{<br />

while [ 1 ]; do<br />

echo "Enter the name of the file containing URL’s (press q to change your<br />

mind)."<br />

read urlfile<br />

if [ ! -e "$urlfile" ] && [ "$urlfile" != q ]; then<br />

# Look for a file, or the quit option.<br />

echo "That file does not exist!"<br />

elif [ "$urlfile" = q ]; then # Check quit option.<br />

echo "Not using a url list."<br />

return<br />

else<br />

echo "using $urlfile."<br />

echo "If you gave me url’s on the command line, I’ll use those first."<br />

# Report wget standard behaviour to the user.<br />

lister=" -i $urlfile" # This is what we want to pass to wget.<br />

return<br />

fi<br />

done<br />

}<br />

cookie_func() # Give the user the option to use a <strong>di</strong>fferent cookie file.<br />

{<br />

while [ 1 ]; do<br />

echo "Change the cookies file. Press return if you don’t want to change<br />

721

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

Saved successfully!

Ooh no, something went wrong!