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.

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

it."<br />

read Cookies<br />

# NB: this is not the same as Cookie, earlier.<br />

# There is an ’s’ on the end.<br />

# Bit like chocolate chips.<br />

if [ -z "$Cookies" ]; then # Escape clause for wusses.<br />

return<br />

elif [ ! -e "$Cookies" ]; then<br />

echo "File does not exist. Try again." # Keep em going . . .<br />

else<br />

CookiesON=" --load-cookies $Cookies" # File is good -- let’s use it!<br />

return<br />

fi<br />

done<br />

}<br />

run_func()<br />

{<br />

if [ -z "$OPTARG" ]; then<br />

# Test to see if we used the in-line option or the query one.<br />

if [ ! -d "$savePath" ]; then # In case <strong>di</strong>rectory doesn’t exist . . .<br />

echo "$savePath does not appear to exist."<br />

echo "Please supply path and filename of saved wget commands:"<br />

read newFile<br />

until [ -f "$newFile" ]; do # Keep going till we get something.<br />

echo "Sorry, that file does not exist. Please try again."<br />

# Try really hard to get something.<br />

read newFile<br />

done<br />

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

# if [ -z ( grep wget ${newfile} ) ]; then<br />

# Assume they haven’t got the right file and bail out.<br />

# echo "Sorry, that file does not contain wget commands. Aborting."<br />

# exit<br />

# fi<br />

#<br />

# This is bogus code.<br />

# It doesn’t actually work.<br />

# If anyone wants to fix it, feel free!<br />

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

filePath="${newFile}"<br />

else<br />

echo "Save path is $savePath"<br />

echo "Please enter name of the file which you want to use."<br />

echo "You have a choice of:"<br />

ls $savePath # Give them a choice.<br />

read inFile<br />

722

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

Saved successfully!

Ooh no, something went wrong!