I’m trying to upload a file using Applescript and Transmit and am not having any luck so far. I first tried using the Folder Action script they include in the Goodies folder. I hard coded in all the ftp connection information and dropped a file into a folder I attached the Folder Action to. Transmit loads as it should, but just “hangs” on the connection window. None of the connection fields are even filled out.
I also tried just scripting the connect command, but almost the same thing happens. Can someone get me started on this? Thanks!
This works for me. If you can get it working, it shouldn’t take much to convert to a folder action.
-- begin user defined variables --
set myUserName to "ftp username"
set myPass to "ftp password"
set ftpServer to "[url=ftp://ftp.server.com]ftp.server.com[/url]"
set initialPathOnFTPserver to "/" -- target directory on server
set fileToUpload to "/path/to/file to upload"
-- end user defined variables --
set tids to text item delimiters
try
set text item delimiters to "/"
set fileName to last text item of fileToUpload
set text item delimiters to tids
on error
set text item delimiters to tids
end try
tell application "Transmit"
activate
set newWindow to make new document at end
tell newWindow
connect to ftpServer as user myUserName with password myPass ¬
with initial path initialPathOnFTPserver with connection type FTP
delete remote item ((ftpServer & initialPathOnFTPserver & fileName) as text)-- deletes file from server if it already exists
upload item fileToUpload
-- disconnect
end tell
--quit
end tell
I’m trying your script and getting a lot of errors. Is this script meant to work with Transmit 1.7? I’m posting in the Mac OS board because I need this to work under OS 9, and as far as I know, Transmit 1.7 is the last version written for OS 9.
tell application “Transmit”
activate
set newWindow to make new document at end
tell newWindow
it gives me an error on the next line at “user” – doesn’t understand it. If I remove “user” it then errors out on “path” saying “Expected ‘given’, ‘with’, ‘without’, other parameter name, etc. but found property.”
connect to ftpServer as user myUserName with password myPass ¬
with initial path initialPathOnFTPserver with connection type FTP
delete remote item ((ftpServer & initialPathOnFTPserver & fileName) as text)-- deletes file from server if it already exists
upload item fileToUpload
-- disconnect
… removed user defined variables block …
– end user defined variables –
set tids to text item delimiters
try
set text item delimiters to “/”
set fileName to last text item of fileToUpload
set text item delimiters to tids
on error
set text item delimiters to tids
end try
tell application “Transmit”
activate
set newWindow to make new document at end
tell newWindow
connect to ftpServer as myUserName with password myPass
upload file fileToUpload
– disconnect
end tell
–quit
end tell
Transmit launches and opens a blank connection window. The error I get then says: “Transmit got an error: Can’t make a document”
Would it be easier/more trouble-free to use a Scripting Addition that allowed me to ftp this file?
Sorry, I’m running Transmit 2.6 in OS X and there are likely enough differences that I won’t be able to help. You might be able to use URL Access Scripting to upload the files. Look for it in your scripting additions folder (I think it’s installed by default).
It doesn’t look like the URL Scripting Additions will help. the only commands they add is “upload” and “download”. No commands to facilitate connecting to a password protected ftp site.
Anyone else? (Please!!! I’m so close to getting this working!!! I just need to get this file uploaded!)
URL Access Scripting has been known to be somewhat touchy at times. The script would probably benefit from some error checking and possibly a lengthened timeout (to deal with connection issues and such).