URL Access Scripting and FTP why is this wrong

Hello,

Why is this script wrong?
It doesn’t work for me. I get an error the the result cannot be transferd in the correct type or something like that.

set SourceFile to “Macintosh HD:Utilisateurs:andrew:Documents:Réseau Bois-Cerf.graffle”
set target_URL to “ftp://username:password@193.134.217.130

tell application “URL Access Scripting”
upload SourceFile to target_URL replacing yes without binhexing
end tell

Hi Andrew,

I guess you have to specify the whole directory path, at least the root directory


set target_URL to "ftp://username:password@193.134.217.130/"

or


set target_URL to "ftp://username:password@193.134.217.130/path/"

Hi Stephan,

No it still doesn’t work. Here is the error message I get back (in french…)
Erreur d’AppleScript
Erreur dans URL Access Scripting : Il est impossible de rendre des données dans le type attendu.

Thanks for your help.

Hi,

Still doesn’t work…

This time here is the answer I get in french:

Erreur d’AppleScript
Erreur dans URL Access Scripting : Le fichier un object quelconque est introuvable.

This time I used “Users” instead of the localized folder “Utilisateurs”.

Thanks for any help.

Andrew Hobson

Re-Hello,

I tried with another file with a much simple filename.

the file was: “Essai.rtf”

I get the AppleScript error: Erreur dans URL Access Scripting : Anomalie d’extension

I really don’t understand the errors return by AppleScript…

Thanks for any help.

Andrew

Hi,

Have you considered using cURL instead of url access scripting? Curl is pretty easy to use; try this:

set SourceFile to "Macintosh HD:Utilisateurs:andrew:Documents:Réseau Bois-Cerf.graffle"
set target_URL to "ftp://193.134.217.130/"

do shell script "curl -u username:password -T '{" & quoted form of POSIX path of SourceFile & "}' " & target_URL

I get this error when I try the curl version:

curl: (3) [globbing] unmatched brace at pos 12

I don’t see where there is an unmatched brace…


set SourceFile to "Macintosh HD/Users/andrew/Documents/Description du réseau/Réseau Bois-Cerf Omni.graffle"
set target_URL to "ftp://193.134.217.130/"

do shell script "curl -u 'HOBSON Andrew':poopoo66 -T '{" & quoted form of POSIX path of SourceFile & "}' " & target_URL

Can you help me?

Sorry, extra punctuation!

set SourceFile to "Macintosh HD/Users/andrew/Documents/Description du réseau/Réseau Bois-Cerf Omni.graffle"
set target_URL to "ftp://193.134.217.130/"

do shell script "curl -u 'HOBSON Andrew':poopoo66 -T {" & quoted form of POSIX path of SourceFile & "} " & target_URL

Hello,

Thank you for your help.

Here are the problems I am experiencing…

With the new version of the “curl” you gave me, it works just fine but:

  • With a simple text file it is OK
  • But with a file that has a Data Fork and a Resource Fork it doesn’t
    work…

My question is this one:

What if I wanted to transfer a complete folder on an FTP server and that
folder could contain simple files and files with a Data + Resource Fork.
What would be the syntax of the curl command?

THANKS a LOT in advance for your help.

Andrew HOBSON

I’m sorry, but I’m not really sure. I’ve used cURL a lot for transferring PDF files and I don’t think I’ve encountered the problem you are having.

Try reading through the cURL manual at http://curl.haxx.se/docs/manpage.html

What output does it give you when you try a non-text file?

edit : well I think I have discovered the problem – a lot of other FTP programs automatically convert the data and resource fork into one Macbinary or Binhex file and send that. I wasn’t having problems specifically because I was using PDFs which apparently don’t require the resource fork for proper transfer.

Do you have Stuffit on your computer? I think that could be used to compress the files first and then upload those. Aside from that, you could also potentially script Cyberduck or Fetch to transfer your files.

With a file with a Data & Resource Fork I get this error:
curl: (18) Uploaded unaligned file size (0 out of 408 bytes)

But with a file that has only a Data Fork everything goes just fine.
Is there a way to transfert a file with MacBinary standard or BinHex standard with this curl command?

Thanks for your help.

Andrew

I’m not really sure of the problem here – is there any chance you can email me the file you are trying to send so that I can try it myself?

My email is bjdemers76 (at) yahoo.ca

Hi,

I will send you this file by e-mail.

But I have something else to say… The FTP server I’m trying to upload this file to, is a MacOS 9 machine with WebSTAR 4.5 as the FTP server. The hard disk is HFS+. Is this a possible problem?

Andrew

Hmm… I think your FTP server might indeed be the problem. I’ll see if I can do anything with your file when I get to work… I don’t have a mac at home :frowning:

This requires DropStuff on your machine… but maybe this will work where the others didn’t:

set SourceFile to "Macintosh HD/Users/andrew/Documents/Description du réseau/Réseau Bois-Cerf Omni.graffle"
set target_URL to "ftp://193.134.217.130/"

--now zip the file before we try to transfer it
tell application "DropStuff"
	zip SourceFile encode Binhex with preserve macintosh content
end tell
set zippedfile to SourceFile & ".zip.hqx"

--now use cURL to send the file over ftp
do shell script "curl -u 'HOBSON Andrew':poopoo66 -T {" & quoted form of POSIX path of zippedfile & "} " & target_URL

--delete zipped file -- using shell script just because it's faster.
do shell script "rm -f " & quoted form of POSIX path of zippedfile

Give that a try?

Hi,

Thanks for your solution, it works just great.

But I have the followin question…

When you upload a file with cURL on an FTP server, are you logged out of the server once the file copy is done?
Or is there a command I can make to be sure to logout when the copy is over?

Thanks for you helps and best regards.

Andrew Hobson