Newbie FTP help needed.

I’m having problems setting up a script to download the contents of a directory to my local machine. I’ve quoted what I have created below. I’ve been reading the O’Reilly book Applescript in a nutshell and I can’t get the examples work either. I’m getting frustrated. What I’m trying to do is connect to the ftp site download the files and then delete them. I haven’t written the deletion part yet because I wanted to get the ftp part working first. I haven’t added the username and password to the script yet for obvious reasons in this post but also I’m not sure how to format those parts in the script. Any help would be greatly appreciated. TIA

I have never done URL access scripting but based on the dictionary and previous exp.
this might work

set filespec to choose folder

-- file default name "Ti550:datafiles:testdate" - folder to download to.

tell application "URL Access Scripting"
	download "" download directory [true] to file specification filespec
end tell

Joe, the only question I have on the code “set filespec to choose folder” will that show me a choose folder dialog? I need something that can run un-attended. The folder on the ftp side will always be the same and the folder on the local computer will always be the same. So I can code those into the script. I will try your code. Thanks.

I tried your script Joe, this is the error I got

What does that mean? I was getting simular errors before when I script would actually compile. What is frustrating to me is that I figured that this would be an easy script to write.

if you want to use the same folder everytime for your destination folder then code it thatway ie

set theUser to "yourUserName"
set thePassword to "yourPassword"

set filespec to "Macintosh HD:Users:jbradfield:Desktop:" as alias -- this will always copy the files to your Desktop folder

-- file default name "Ti550:datafiles:testdate" - folder to download to.
set GoHere to theUser & ":" & thePassword & ""

tell application "URL Access Scripting"
	download GoHere download directory [true] to file specification filespec
end tell

this may seem obvious but make sure to change YourUserName to your user name
and likewise with the password

Thanks Joe, for the info. Do you have any idea why I am getting the can’t convert error?

paste your script and we can check it out

change the username/password if needed to maintain privacy

 set filespec to choose folder

tell application "URL Access Scripting"
	download "****r:*****" download directory [true] to file specification filespec
end tell

Joe, I basically took your example and tried it out. I figured it would put a dialog box to choose the “deposit” directory and it did. I was kind of surprised that it errored out.

like i said before i have never done URL access scripting but maybe i can help you offline with your username and password email me at if you want to see if that will work

unless someone else in the forum sees what is wrong

The UNIX rsync would be my tool of choice for the task as it was designed just for this kind of thing, and can optionally use an ssh tunnel for secure communications (ftp is a major security risk as it sends passwords in the clear, and should be avoided for all applications (except anonymous access)). rsync could be called from a do shell script. It does requre rsync on the other end, however, so YMMV.

Does this make any difference?

set filespec to choose folder

tell application "URL Access Scripting"
	download "****r:*****" to filespec with download directory
end tell

– Rob

The error messge changed to

So I think that is progress. :slight_smile: any suggestions now?

Admin note (13 Apr 2006): I believe the URL needs to start with “ftp://”

tell application "URL Access Scripting"
	download "ftp://****r:*****" to filespec with download directory
end tell

Rainy Day, thanks for the info. I think the FTP site is on a windows box so I might be out of luck. I do have a question. I understand your security concerns regarding using FTP. I’m going to detail my setup and please tell me if I’m still risking anything.

I’m working with an application where remote sites deposit files in the ftp directory. This is done outside of my Applescript application. My Applescript application is going to pull those deposited files inside the firewall to be processed. The ftp box is in the DMZ zone and my applescript is going to be used internally only. That is why I figured security wouldn’t be too much of a problem. Since my process takes place inside the firewall.

Nope, I can’t get it to work either. Maybe someone can offer a curl script to do this. Dan S., are you readin’ this? :wink:

– Rob

As regards the traffic inside the firewall, you might be okay, assuming, of course, that there are no machines inside the firewall to worry about (such as a machine behind the firewall which may have been compromised and is be relaying info to an outside agent). However you can never be too cautious nor have too much security, so why not use a secure protocol on the inside? Just as an extra layer of security. There are so many clever ways of compromising a system and/or network.

Now regarding the first part: If those remote sites are depositing files via ftp by any method other than anonymous ftp (e.g. they have an account), that machine is definitely at risk as those passwords are sent in the clear, along with userID’s. It wouldn’t be difficult for an attacker, therefore, to gain access to your server. That gives the attacker a foothold behind your firewall. (The risk can be mitigated somewhat by disallowing shell access to those accounts.)

Even though a Windoze machine is involved here (your server?), sftp would still be an option even if rsync isn’t. sftp is a secure form of ftp, and Windoze clients and servers for it do exist. Also, ftp can be done through an ssh tunnel, which is just about the same thing as sftp, so setting up an ssh server is another way to go about it.

I suppose i should ask this question: Why is the server running Windoze? Why not drop OpenBSD on the box instead? It runs on Intel hardware and is infinitely more secure.

Actually the FTP server is out of my control. I’m working in a Government Agency and have to take what is available. I guess I’m trying to make the best of a bad situation. :slight_smile: I wouldn’t need to be doing Applescript if some of my other ideas/suggestions were possible. :slight_smile:

Yes, well the Department of Homeland Insecurity has adopted Windoze as their platform of choice, haven’t they? Must be a goverment project, alright! :smiley: Personally, i think we’re screwed (if this is typical of the quality of decisions they’re making to keep us “safe”). :?

I hate to burst your bubble but I’m not working for that department. I’m working for the Ohio Department of Education. I would agree with your assesment if I was working for the department of Homeland Security.

I don’t think anyone (e.g. local, state or federal government, nor most of the private sector) is really taking security as seriously as they should. As we become more and more networked, and dependent on those networks for all kinds of stuff, it’s only a matter of time before “terrorists” turn their attentions in that direction. Even the “amateur” virus writers are wrecking major havoc. The cost of recent MS viruses have exceeded the cost asssociated with picking up after 9-11.

But it sounds like your hands are tied. You might, however, consider putting some security recommendations in writing. Never know, maybe somebody will pay attention. YMMV.

So how would you rather be doing this?