Curl Shell Script - Create New Folder on FTP server - Syntax query.

Hi All,

I have a script to push files to an FTP server, but now need to generate new directories for the files. I found the following code, but I don’t have the syntax correct :


property ftpserverPath : "ftp://ftp.mycompany.com/"
property ftpserverpathnewdir : "ftp://ftp.mycompany.com/new_dir/"

		do shell script ("curl --ftp-create-dirs -T " & ftpserverpathnewdir & " -u " & user_name & ":" & pass_word & ftpserverPath)

This generates the following error :
Finder got an error: curl: no URL specified!
curl: try ‘curl --help’ or ‘curl --manual’ for more information

  1. Do I have the ‘curl’ command correct?
  2. Where is the new directory name specified? In the variable?

Nb. The reason there’s a finder error is I have the other curl shell command inside finder tell to use a ‘repeat with’ statement to upload multiple files from a folder. (This part of the script works fine).

The goal of the script is to specify a local folder, login to the FTP server, create a new folder a current date string then transfer all the files in the local folder to the FTP folder.

Thanks in Advance.

Matt.

Hi Matt,

This works.

property ftpHost : "[url=ftp://ftp.blablabla.com]ftp.blablabla.com[/url]"
property ftpChangeDir : "London"
property ftpUsername : "yourUsername"
property ftpPassword : "yourPassword"
property ftpFileToUpload : "/Users/adminosx/Desktop/test.jpg"

do shell script ("/usr/bin/curl --disable-epsv --ftp-create-dirs -T " & quoted form of ftpFileToUpload & " -u " & ftpUsername & ":" & ftpPassword & " " & "ftp://" & ftpHost & "/" & ftpChangeDir & "/")

Ame

Thanks Ame, that works.

Is it possible to generate a folder WITHOUT placing a file inside?

Thanks again.

Matt.

Hi Matt,

This generate only missing folder/s:

do shell script ("/usr/bin/curl --disable-epsv --ftp-create-dirs -u " & ftpUsername & ":" & ftpPassword & " " & "ftp://" & ftpHost & "/" & ftpChangeDir & "/")

Ame

Hi Ame,

This works - I was close :


do shell script ("/usr/bin/curl --disable-epsv --ftp-create-dirs  & " -u " & user_name & ":" & pass_word & " " & ftpserverpathxml & shortDate & "/")

I’d taken out the -t switch and the file path but left the ‘&’ in!! aarrgghh.

Thanks again.