How to decompress and run .app?
I'm trying to execute an AppleScript .app thats compressed.
unzip -p file.app.zip | open -
or
open < $(unzip -p file.app.zip)
Is this possible?
As you are dealing with a zip compressed application .app
, which is an application bundle with many files in it, I believe you'll have to extract the app to disk first to open it, because the open
command to open an application is in the form of open -a ...
and does not take input from stdout
.
The following assumes that the app name in file.app.zip
is file
or the exact name of the app within the .zip
file:
unzip -oq "file.app.zip" -d /tmp; open -a "/tmp/file.app"; sleep 1; rm -r "/tmp/file.app"
The above compound command line extracts the file.app.zip
to /tmp
and then opens it, waits a second and then deletes the /tmp/file.app
. Note that the value of the sleep
command may need to be adjusted in order to not have the app deleted before it's opened and finished running.
Note that the contents of /tmp
, which is actually /private/tmp
, is automatically deleted upon reboot. So the compound command line could be shortened if you don't care if the app remains in /tmp'
until next reboot:
unzip -oq "file.app.zip" -d /tmp; open -a "/tmp/file.app"
You are asking the open
command to open content from stdin
. open
can be made to read from stdin
but it will open the contents in at text editor--which isn't what you want.
Try using osascript
directly:
If the zipped file is simply AppleScript, then you accomplish this with the following.
unzip -p file.zip | osascript -
From the osascript
manpage:
osascript will look for the script in one of the following three places:
Specified line by line using -e switches on the command line.
Contained in the file specified by the first filename on the command line. This file may be plain text or a compiled script.
Passed in using standard input. This works only if there are no filename arguments; to pass arguments to a STDIN-read script, you must explicitly specify '-' for the script name.