unzip with secret password

I have an encrypted ZIP file with a password of “123”. I want an Applescript/shell command to decrypt and expand without User intervention. I have tried many ways to do it using the suggested routine:

unzip -P mypassword myzipfile.zip

But I get an error which includes the actual file that’s already zipped…
error “error: cannot create feb-csv.png
error: cannot create ._feb-csv.png” number 50

Any ideas?

do shell script "unzip -P 123  /Users/adrianshome/Desktop/outp/outp.zip"

Hello.

I guess you are trying to unzip the files, on the root of your file system *, and that you (luckily) didn’t have the rights to do so, try to change directory to the Desktop for instance, at the start of your do shell script. Hopefully that works better.

(Untested.)

do shell script "cd ~/Desktop ; unzip -P 123 /Users/adrianshome/Desktop/outp/outp.zip"

Edit

I had a quick glance at the unzip manual in the Terminal window (man unzip), and it also has a -d option for specifying the extraction dir.

*

set theDir to do shell script "echo $PWD"
log theDir
-->	"/"

Wonderful! This works when destination is Desktop:
do shell script “cd ~/Desktop ; unzip -P 123 /Users/adrianshome/Desktop/outp/outp.zip”

But I have a dmg I want to distribute with the script+zip files on it. I want to unzip to this destination on any User’s machine:
Macintosh HD/Applications

Tried replacing ~/Desktop ; with Macintosh HD, but the space causes a problem.

Hello.

It so happens, that you won’t have the rights to execute that script with extracts to the machine’s Application folder.

Then you’ll have to execute the do shell script with administrator privileges but you could extract to the users Application folder, but I think you’ll have to check for its existance first, and make the folder isn’t already there.

However the path to the applications folder of the machine is /Applications, the path to the users application folder is ~/Applications.

Thank you. "cd /Applications ; " now points to the destination.

The dmg will be downloaded and displayed on another User’s computer, so I am trying to solve that.
I cannot get the correct path for the source, which is a entitled “6.dmg/outp.zip” on the Desktop.

I’ve tried:
do shell script “cd /Applications ; unzip -P 123 -o ~/6.dmg/outp.zip” with administrator privileges
do shell script “cd /Applications ; unzip -P 123 -o ~/6/outp.zip” with administrator privileges
do shell script “cd /Applications ; unzip -P 123 -o /6/outp.zip” with administrator privileges

But I get errors like:
error “unzip: cannot find or open /6.dmg/outp.zip, /6.dmg/outp.zip.zip or /6.dmg/outp.zip.ZIP.” number 9

Hello.

When your dmg file is mounted, it is mounted under “Volumes” so the correct path would be /Volumes/6.dmg/outp.zip

hello MsUsrII,

I tried this and many other variations. Getting the same error…
error “unzip: cannot find or open Volumes/6.dmg/outp.zip, Volumes/6.dmg/outp.zip.zip or Volumes/6.dmg/outp.zip.ZIP.” number 9

???

a POSIX path starts always with a slash representing the root directory of the startup volume (the tilde is the equivalent to /Users/).
So the path to the folder Volumes is

/Volumes

Solved it by adding slash “/” to Volumes and removing the “.dmg” extension…

do shell script “cd /Applications ; unzip -P 123 -o /Volumes/6/outp.zip” with administrator privileges

Thanks again for your brilliant help!

Thank you too StephanK for your insight :slight_smile: