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
Sort By: 

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.

Reply

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

Ha..just noticed the florida thing cool.


theFile is the variable passed to the script by Audiojack. So basically I just want to upload the file which is recorded by Audiojack and the name is passed to the script as theFile. Its path will be ~/music/Audiojack...

Reply

Dec 12, 2012 7:57 PM in response to Frank Caggiano

Thanks mate, I am still trying to make this work. I am not getting any errors. The file however is not copied across so I'm trying to see whats going on. I modified it slightly since the file name contains spaces.


do shell script "curl -T " & POSIX path of theFile & " ftp://......

Reply

Dec 13, 2012 3:28 PM in response to Cole Tierney

Yeah I marked it solved because its not giving me any errors like before. For some reason the file doesn't get copied across. I wish i could check a log somewhere. The console doesn't display any related entries.


I tried -u username:password. This is giving me a host error.

Reply

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

Reply

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

Reply

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

Reply

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

Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

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 Account.