Transmit upload

I’ve created a script to ftp files with Transmit, based largely on Rob’s synchronize script, but I am getting the following error about my upload line when I run the script:

“NSCannotCreateScriptCommandError”

here is the script:


on open dropped_files
	send_all_of(dropped_files)
end open

on send_all_of(those_files)
	set myFTPAddress to "your_address"
	set myUserName to "user"
	set myPass to "password"
	set initialPathOnTheirServer to "/usr3/GLD/images"
	
	tell application "Transmit"
		set newWindow to make new document at end
		tell newWindow
			connect to myFTPAddress as user myUserName with password myPass with initial path initialPathOnTheirServer
			repeat with a_file in those_files
				tell window 1 to upload file (a_file as text)
			end repeat
		end tell
	end tell
end send_all_of

Anyone have ideas about this error? Anyone have successful samples of upload syntax?

thanks,
Andy

What happens if you change this:

tell window 1 to upload file (a_file as text)

To this:

upload file (a_file as text)

I ask only because you are issuing 2 ‘tell window’ commands.

Oops, I’ve been cutting and pasting umpteen versions to try and debug this and had missed the 2 tell window lines. Anyway, taking the second tell window out didn’t solve anything, I get the same error message refering to that line. Thanks for catching it though.

I switched to a droplet because I thought maybe I wasn’t refering to the file to be sent correctly, and a droplet would help clear that up, but no.

Andy

I can’t get an upload to work either. I’ve requested clarification on the ambiguous dictionary entry from a Panic programmer. :wink:

OK, glad to hear I’m not going crazy. I emailed Panic last week about this and haven’t gotten a reply yet. I hope one of us gets some response.

Andy

I just got a reply from one of the programmers (also one of Panic’s founders). He said:

My test script does target a document and I’ve tried numerous variations on the upload command, without success. I’ll try to contact someone else at Panic. I thought this would be an easy one for a programmer to answer. :confused:

I got a reply from Cabel Sasser at Panic telling me that, yes the syntax had changed, and they were working on some applescript examples that they would post to their site.

They were, they did, and here’s a link

http://www.panic.com/transmit/support.html

Anyway, the new syntax does work, and is pretty “interesting” to this novice.


tell application "Transmit"
	
	make new document at before front document
	
	tell document 1
		
		if (connect to "ftp_server" as user "whoever" with password "whatever") then
			
			if (set their stuff to "/target_directory") then
				
				upload item "/Users/me/Desktop/my_file.pdf"
				
			end if
			
		end if
		
	end tell
	
end tell

One thing I noticed right away is that both the “their stuff” and “your stuff” use the Unix path style. I haven’t tried doing it without the “if then” structure yet… just happy to have a solution.

Andy

Interesting indeed, and not very conventional in my opinion! I know that during my tests, I used ‘item’ as the reference, and I tried both types of paths, but I guess I never tried them at the same time. FYI, I didn’t bother with the conditional stuff and it worked fine. Thanks! :slight_smile: