Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

simple applescript curl command

Guys I am stuck on this simple curl upload upon completing an audiojack recording. i just want to upload the file to ftp.


on process(theFile)

do shell script "curl -T 'theFile' ftp://username:password@ftp.com/password@ftp.com/"


end process


Is there an issue in the syntax ?

Thanks!

iMac, Mac OS X (10.7.4)

Posted on Dec 12, 2012 5:01 PM

Reply
17 replies

Dec 12, 2012 6:39 PM in response to Frank Caggiano

Hey,


Yes the curl command works in applescript if i type it in as:

do shell script "curl -T thefile ftp://username:password@ftp.com"

It works if theFile is replaced by an actual path of a file.

It seems that I am doing something wrong either in putting theFile in quotes because the error is.. Cannot find 'theFile'

I have tried without quotes as well.

Dec 13, 2012 3:43 PM in response to Frank Caggiano

I ran this and it works which tells me that that the command syntax seems correct. The issue must therefore lie with the varaible that is being passed from audiojack.


--on process(theFile)

set theFile to "filepathf"

do shell script "curl -T " & theFile & " ftp://username:password@........


--end process



This is what I used as the template from Audiojack


on process(theArgs)


--Into iTunes ye files shall go

tell application "iTunes"

repeat with theFile in theArgs

add theFile

end repeat

end tell


end process

Dec 13, 2012 5:59 PM in response to kap_australia

If the filename in the variable theFile has spaces in it then that will be a problem. I hate spaces in filenames!


To things:

First you will need to use the absolute path for the file. When the do shell script runs you can't rely on it being in a specific directory. You also can' rely on the environment being set up. So if you wanted to list out your Desktop folder for example you would need to do:


do shell script "ls /Users/homefolder/Desktop"


Second if the file name has spaces in it (or even if it might) you will need to do


do shell script "curl -T '" & theFile & "' ftp://username:password@........


That is add a single quote before the double quote after the -T and then add a single quote after the double quote before the ftp command. No spaces between the single and double quotes,


These should finally get this going.


good luck

Dec 13, 2012 6:32 PM in response to Frank Caggiano

It definintely has spaces. The file is iTunes 20121214 1327.mp3 which is why I used the POSIX command before.

Anyhow I inserted the quotes as you suggested. This is the error I get:


NSLocalizedFailureReason: curl: Can't open 'Macintosh HD:Users:Username:Music:Audio Hijack:iTunes 20121214 1327.mp3'!

curl: try 'curl --help' or 'curl --manual' for more information

Dec 13, 2012 6:58 PM in response to kap_australia

Ok the quotes have taken care of the spaces in the file name but the problem here is that you are sending a OS X file spec to the shell and that won't work.


In other words the shell wants /foo/bar and you're sending foo:bar


This little script works and demonstrates what you need to do.


set theFile to (path to desktop) as string


do shell script "ls '" & POSIX path of theFile & "'"


Not knowing how you're setting theFile makes it tough to get more specific

simple applescript curl command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.