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?
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.
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.
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.
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.
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!