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.
The argument for osascript -e
can contain newlines:
osascript -e 'set x to "a"
say x'
You can also specify multiple -e
arguments:
osascript -e 'set x to "a"' -e 'say x'
Or if you use a heredoc, bash
interprets three characters (\
, $
, and `
) between <<END
and END
but no characters between <<'END'
and END
.
osascript <<'END'
set x to "a"
say x
END
Edit:
Since osascript can operate with a heredoc (ie take input from /dev/stdin) then one can just write the script as a whole file and prepend with the correct shebang line:
#!/usr/bin/env osascript
set x to "a"
say x
This also allows you to save your apple script as a actual program in ~/Applications/.app using the following procedure (changing for your script's name):
mkdir -p ~/Applications/<APP_NAME>.app/Contents/MacOS
touch ~/Applications/<APP_NAME>.app/Contents/MacOS/<APP_NAME>
open -A TextEdit ~/Applications/<APP_NAME>.app/Contents/MacOS/<APP_NAME>
Ensure that both the script file in .../MacOS/ and the matches
Best Answer
You can provide multiple
-type
options with-o
, such as-type d -o -type f
in a single command.-o
matches all parameters, so the-name
is provided twice in the above command.