Need a bit of help running a couple lines of bash in applescript. Maybe straight bash is best? Preface this by saying I will be launching this script whether it be applescript or bash script with Alfred.app.

Sorry to be so blunt and unknowledgable but I need to run a couple lines of bash in an applescript. I think a simple bash script is capable but I do not know for sure. Here are the details (note that the commands should probably be different so if you have suggestions, please feel free to state them as they are probably correct):

I want the script to


rm ~/Library/Vidalia/vidalia.conf'
unzip ~/Library/Vidalia/vidalia.conf.zip'
launch Vidalia.app


Step below I do not believe is possible since the Vidalia.app is not scriptable and I don't want the applescript/bash script to be running until Vidalia quits... but if it's possible to implement without the script needing to stay open:

4) On quit of Vidalia.app rm ~/Library/Vidalia/vidalia.conf

Is this possible. I can use bash or applescript whatever is easiest for you guy's &amp; gals to help me with. If I could get the first three steps to run I would be plenty happy! Thanks for your time and sorry for my lack of knowledge. Any tips or pointers are welcome.

Heck, I don't even know if those are the "proper" shell commands to use, they did the job but if they are "sound" I do not know.

Thank you for your time and patience.

UPDATE - Question: How to move unzipped file into different directory?

Okay I have one last question. How would I do this same sort of action, but I wanted to keep vidalia.conf.zip in another directory? 

Say, for example, an external volume named tor - I moved into the mounted volume named tor with pushd, but when I go to extract the file with what I think should work -d I get the error that I  cannot create extraction directory 

Which is good because I don't want to replace the directory, just move what get's unzipped into the pre-existing directory. Yeah, I will probably have to remove the file already there depending on what I am doing so what I have looks like this...

pushd ~/Library/Vidalia/
rm vidalia.conf
popd
pushd /Volumes/tor
unzip vidalia.conf.zip -d ~/Library/Vidalia/
popd


I haven't quite tried this too much once I ran into the error with plain old -d. As I was typing this I realized that I had to be navigating directories more with pushd and then out with popd.  Originally I just had lines 4 and 5 but added the top 3 to remove the .conf that currently is there ... if ... it is there...

Which bring me to one more question… Is it harmless to tell bash to remove a file that doesn't exist? I would have no idea where to even start with if then statements.

Lastly, can anyone recommend a good beginners intro to Bash book? I'd love to actually learn this stuff instead of just having to google and then turn around and bug you all. Thank you again for your help. You solved my earlier problem perfectly, I even learned a lot from the simple example (I think.)

Cheers!
As @laaph mentioned, if you just want to run bash commands, use a bash script.

There are, however, a few issues with your commands.

Your script has to look like:

#!/bin/sh

pushd ~/Library/Vidalia
rm vidalia.conf
unzip vidalia.conf.zip
popd
open /Applications/Vidalia.app


If you didn't change to the correct directory, unzip would unzip the file into your home directory, or wherever you launched your script from.

There are ways to look for when an app quits, but in your case this seems useless, you're removing the .conf whenever you launch the script anyway. But if you really want that, you could simply do:

#!/bin/sh

pushd ~/Library/Vidalia
rm vidalia.conf
unzip vidalia.conf.zip
popd
open -W /Applications/Vidalia.app
pushd ~/Library/Vidalia
rm vidalia.conf
popd


(This would make the script wait until you close the app, and then it'd delete the configuration file. Again though, this is useless and redundant if you'll be only launching the app with the script.)

Also, you could try a simpler solution: I assume that what you want is just to have the same vidalia.conf whenever you start the program. If that's the case, try just making the .conf read-only.