Jump to content




Applescript/custom function "do shell script" syntax?

applescript ftp shell

  • Please log in to reply
5 replies to this topic

#1 OFFLINE   Moon Rabbit  novice

Moon Rabbit
  • Members
  • 10 posts
  • LocationPortland, OR
  • FM Client:11 Advance
  • Platform:Mac OS X Lion
  • Skill Level:Intermediate
  • Time Online: 1h 5m 51s

Posted 20 January 2012 - 10:56 PM

I've been trying for 3 days to figure out the syntax for an FTP Upload custom function (downloaded from briandunning.com), but I can't get it to work. It always fails with error -2740, "an unknown token can't go here," which tells me nothing. Anyone care to check out my script and offer some pointers? I'm sure there's a syntax error, but I can't find it. I want to hard-code the username and password, but the password contains special characters (parentheses), and I'm not sure how to escape them:

i,e, ythr(i.K9)56
I've tried various escaping approaches: ythr\(i.K9\)56 , "ythr" & "\(" & "i.K9" & "\)" & "56", etc.

FTPUpload (path, directory, file)


"
set thePath to quoted form of \"ftp://<username>:<password>@ftp.remotehost.com/targetfolder/\"

do shell script \"curl -T\"  path & "/" & directory & "/" & file thePath

"

Any ideas?

#2 OFFLINE   comment  consultant

comment
  • Members
  • 21,137 posts
  • Time Online: 187d 10h 40m 8s

Posted 21 January 2012 - 03:24 AM

Do you have a working AppleScript? That is one that works when run from AppleScript Editor?

---
P.S. Could I please ask you to change your avatar? It's very distracting.

#3 OFFLINE   Moon Rabbit  novice

Moon Rabbit
  • Members
  • 10 posts
  • LocationPortland, OR
  • FM Client:11 Advance
  • Platform:Mac OS X Lion
  • Skill Level:Intermediate
  • Time Online: 1h 5m 51s

Posted 21 January 2012 - 09:33 AM

Haven't posted in a while, so the first thing I thought was "I wonder how many people are going to post to ask me to change my avatar?

Actually, the entire script step is

Perform Applescript (calculated)
FTPUpload($path, $directory, $file)

where $path, $directory and $file are local variables

#4 OFFLINE   comment  consultant

comment
  • Members
  • 21,137 posts
  • Time Online: 187d 10h 40m 8s

Posted 21 January 2012 - 10:47 AM

I suggest you step away from the custom function and do some experimenting in AppleScript Editor or directly in the terminal until you find out what kind of escaping is necessary and acceptable in cURL. Until then, this is not a Filemaker or even AppleScript issue.

I suspect that as long as your password doesn't contain quotes, colons or at signs, it shouldn't need any escaping. But that's merely a guess.

Edited by comment, 21 January 2012 - 10:49 AM.


#5 OFFLINE   Lee Smith  *$ time

Lee Smith
  • Staff
  • 8,465 posts
  • FM Client:12 Advance
  • FMGo:iPhone / iPod Touch
  • Platform:Mac OS X Lion
  • Skill Level:Expert
  • Membership:TechNet
  • Time Online: 96d 2h 44m 23s

Posted 21 January 2012 - 10:16 PM

View PostMoon Rabbit, on 21 January 2012 - 09:33 AM, said:

I wonder how many people are going to post to ask me to change my avatar

I had the same concern as you, and was waiting to see if anyone actually did reply, as I tagged your post for follow-up in case no one did, and to see what others had to say about it. Personally I couldn't concentrate on your question with your avatar on-screen, maybe others had the same problem.

I'm curious as to why you would use it when you, yourself, thought it  was over the top?

Lee

#6 OFFLINE   Luis Yax  newbie

Luis Yax
  • Members
  • Pip
  • 1 posts
  • Time Online: 8m 14s

Posted 24 January 2012 - 12:20 AM

Just use a simple shell script, see the code below:

Enjoy!

-----------------

#!/bin/sh

ftpserver="ftp.server.com"
remotepath="Import"
ftplogin="myuserid"
ftppass="mypass"


function ftpfile {
ftp -n $ftpserver <<INPUT_END
quote user $ftplogin
quote pass $ftppass
cd $remotepath
prompt off
mput TheFile2BUploaded.csv
exit
INPUT_END
}

ftpfile
exit
---------


Back to AppleScript & Automator



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

FMForum Advertisers