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 & 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!