I am updating a script I had working a while ago. The script basically reads my ftp server through cyberduck and sends back a list of folders so I can choose which one I want to delete. I made a minor tweak, but I am now getting the following error.
Any ideas or a better way of doing this?
tell application "Safari"
set URL of document 1 to "http://myurl.com/clients/list.php"
delay 2
set theText to text of document 1
quit
end tell
set myList to paragraphs of theText as list
set myChoice to choose from list myList
if myChoice is false then return
repeat with theChoice in myChoice
tell application "Cyberduck"
set theServer to "[url=ftp://ftp.myurl.com]ftp.myurl.com[/url]"
set theUser to "username"
set thePassword to "password"
set theProtocol to "ftp"
set theRemoteFolder to "/httpdocs/clients/"
set theBrowser to (make document)
with timeout of 300 seconds
tell (theBrowser)
set the «class enco» to "UTF-8"
set «class hidd» to true
«event CYCKCoCt» given «class HoSt»:theServer, «class PrCl»:theProtocol, «class UsMe»:theUser, «class PaRd»:thePassword
«event CYCKGoTo» given «class PaTh»:theRemoteFolder
delete given «class PaTh»:theChoice
«event CYCKDiCt»
quit
end tell
end timeout
end tell
end repeat
AppleScript: 2.6.1
Browser: Safari 537.85.13
Operating System: Mac OS X (10.8)
It would appear that CyberDuck’s developer discontinued AppleScript support years ago and has no plans to reintroduce it.
Cyberduck 4.6.5 has no AppleScript dictionary whatsoever.
Well that’s great news…I just looked for a dictionary for filezilla, but it doesn’t appear they have one either? Any other suggestions about how to do this? I’m not too familiar with terminal commands.
I Applescript Panic’s Transmit with great success. (http://www.panic.com/transmit/)
Hi,
this is a solution using cURL.
As cURL is not able to delete non-empty directories directly, the script walks recursively through the directory hierarchy first deleting all files then the empty dirs
-- ******** server access data
property server : "[url=ftp://ftp.myurl.com]ftp.myurl.com[/url]"
property baseDirectory : "/httpdocs/clients/"
property server_username : "username"
property server_password : "password"
-- ********
property credentials : " -u " & server_username & ":" & server_password
set {_directories, _files} to listDirectory(baseDirectory)
set chosenDirectories to choose from list _directories with prompt "Choose directories to delete" with multiple selections allowed
if chosenDirectories is false then return
repeat with aDir in chosenDirectories
removeDirectory(baseDirectory & aDir & "/")
end repeat
on listDirectory(thePath)
-- read directory from server
set command to "/usr/bin/curl " & quoted form of (server & thePath) & credentials
set directoryData to paragraphs of (do shell script command)
set theDirs to {}
set theFiles to {}
repeat with aLine in directoryData
set isDirectory to character 1 of aLine is "d"
set itemName to do shell script "echo " & quoted form of aLine & " | sed -n -e 's/^.*:[0-9][0-9] //p'"
if itemName is not "." and itemName is not ".." then
if isDirectory then
set end of theDirs to itemName
else
set end of theFiles to itemName
end if
end if
end repeat
return {theDirs, theFiles}
end listDirectory
on removeDirectory(aDirectory)
set {_directories, _files} to listDirectory(aDirectory)
if (count _files) > 0 then
repeat with aFile in _files
do shell script "/usr/bin/curl -Q " & quoted form of ("DELE " & aDirectory & aFile) & credentials & space & server
end repeat
end if
if (count _directories) > 0 then
repeat with aSubDir in _directories
removeDirectory(aDirectory & aSubDir & "/")
end repeat
end if
do shell script "/usr/bin/curl -Q " & quoted form of ("RMD " & aDirectory) & credentials & space & server
end removeDirectory
No, Filezilla has never been scriptable - AND I now consider it crapware because it installs adware.
I would probably spend money on Transmit or Fetch (I own both), but there are at least 2-3 others that are scriptable.
On the other hand you might be able to do what you want via (s)ftp
either in the Terminal or via do shell script.
How use ftp through command line on OSX.
And then there’s curl
which comes stock on OSX. (Example)
Or wget
which you’ll have to install with MacPorts or a similar package installer. (Example)
I use curl
virtually every day for http operations, but I’ve never really used it for ftp.