Author Options:

Apple scripting question? Answered

I am new to Apple computers, I just got an older system off of ebay for testing purposes and so that I can learn how to use them.  (I want to go into IT for a living, so I will need to learn how to use them.)

I need a little help getting started with my first project.  I have made a working program for what I want to do in Windows as a batch file (which I then compiled into an .exe).  For a company that I am starting, people often need to send me large files, and I want to give them a way to do this.  I have two FTP servers (one in the cloud, and one at home that my parents make me shut down every night).  Since these files are large enough that it takes awhile to download them from my cloud server, my script automatically selects which server to use based on the current time.  It then prompts the user to drag and drop their file into the dos window to select the files they wish to upload.  After that, it creates an FTP script which is then executed using the ftp /s command.  This program works great.

I would like to get this program working on my mac as well (I realize that I probably can't use the same script, I will have to change it).  I considered using a bash script, but it seems that you would have to start the script from terminal (it can't just be executed by clicking on it like in windows).  I've also looked at automator, but as far as I can see it doesn't even have the ability to upload to FTP.

At this point, I just want to make an easy way for people to upload to a specific FTP server without having to enter usernames, passwords, IP addresses/ urls, etc.  I don't even care if it automatically switches between servers like my other script... that is a bonus.  To any mac programmers out there, if you were going to do this; where would you start?  (Stick with bash, applescript, automator, another programming language, etc.)



The forums are retiring in 2021 and are now closed for new topics and comments.

Best Answer 7 years ago

She'll scripting is going to be the most robust, though with apple script you may be able to leverage a an app to do the FTP heavy lifting for you. In other words there are a bunch of ways to do it, including grabbing Xcode and building an AppleScript app.

For a quick and dirty first attempt, I'd try it in Automator first, making liberal use of the 'do shell script command' to do the FTP. One gotcha, is that AppleScript does not wait for the command to finish, so you'll need to keep looping to see if the file is downloaded. You can launch the Automator as a cron job as well.

This should get you started, but feel free to follow up with any questions. I've been doing something similar for work, so I've been through this. I'm using a straight AppleScript (not Automator) but part of that is just historical rather than by design.


Answer 7 years ago

Thanks for the information! :)