Possible to FTP a .zip then extract on Server via Applescript?

Hello All,

I generate Websites and Videos for Real Estate automatically and upload the Web Folder via FTP to a GoDaddy Server.

Is is possible to upload a zip file and then extract that zip on the Server via Applescript? This would obviously make the upload process much quicker. ie uploading 1 big file vs. 700 little ones.

I have the FTP process via curl, but would I need to put an extractor widget on the server to accomplish this?

PLEASE, dont spend time on this, I just wanted to hear from the community whether this is possible and a possible nudge in the right direction.

Thank you all!

Model: Trash Can
Browser: Safari 537.36
Operating System: Mac OS X (10.10)

I don’t think you can send an unzip command via simple FTP.

If you were to have the Applescript mount the FTP server in Finder, it could perform the file copy and then the unzip. But I’m pretty sure that what “perform the unzip” does in the context of a mounted remote drive in the Finder is actually to copy the archive back to a temp folder on your local machine, unzip it, and then copy the files back to the server… so not a good idea.

If you have SSH access to the server, then Applescripting this is probably a good idea. Or just shell scripting it. Upload the file via FTP, then SSH in and unzip it. That will definitely happen server side and would be both easy and useful to script.

Or if you don’t have SSH access but can run a script server-side, there are various “hack-y” ways to do it - which I think is the “Extractor Widget” you mentioned.

Another approach is to change the default FTP server running on the other end with one that has an auto-unzip feature.

https://www.pureftpd.org/project/pure-ftpd
http://www.wftpserver.com/download.htm

If you don’t have ssh access or other administrator access to the server, I don’t think you have any option better than just uploading all the files individually.

t.spoon,

That is wonderful information! Definately more than a nudge!

I enabled ssh on the Godaddy Servers and just looking into how to script it.

Thank you so much for the info! I am more than grateful!

I LOVE THIS SITE! Everyones knowledge is invaluable and saves me so much time!

Hi All!

So I finally got around to cobbling the code together. FYI, I am using GoDaddy.

Is there a better/more reliable way to do this?

I hate using keystroke but I cant find another way to control terminal. I tried using " && " to join commands together but I couldnt make it fly.

This works, but doesnt make me happy.


tell application "Terminal"
	activate
	do script "ssh username@xxx.xxx.x.xx"
	delay 1
	tell application "System Events"
		keystroke "password"
		keystroke return
		delay 2
		keystroke "unzip public_html/IMLS246810.zip -d public_html/IMLS246810/" 
		keystroke return
	end tell
	
end tell

Any thoughts on refining this at all?

It is also way slower than I would have expected :frowning:

Thanks ALL!

This is an update for anyone who may be going through the same thing

I ended up using sshpasss which can be installed via homebrew

I wanted to use the literal Password rather than a Key for a few reasons.

This solution allows my code to wait for the end of the run, whereas the previous solution I proposed used System Events and Keystrokes making detecting the finish and closure of a Terminal window troublesome and unreliable


do shell script "/usr/local/bin/sshpass -p password ssh -o StrictHostKeyChecking=no username@xxx.xxx.x.xx unzip -o public_html/IMLS246810.zip -d public_html/IMLS246810/"

Oh and its sooooo much quicker

Hope it helps someoneelse

Have a great day!