Re: url access scripting
Re: url access scripting
- Subject: Re: url access scripting
- From: "Daniel A. Shockley" <email@hidden>
- Date: Sun, 23 Feb 2003 23:54:49 -0500
Date: Mon, 17 Feb 2003 13:17:10 -0500
Subject: url access scripting
From: John Pilling <email@hidden>
To: email@hidden
has anyone a solution to the upload command no longer working in
applescript 1.8.3 it always returns -43 file not found even when the
file exists..
os 9.? - even the script supplied in the applescript guidebook on url
access scripting do not work. download works ok but upload always
returns -43.. actually in the API URLSimpleUpload doesn't work either
it returns -43 too..
Here's a simple AppleScript handler that allows you to do an FTP
upload. I posted a copy at <
http://www.danshockley.com/codebits.html>
in case the email mangles the code here.
-- SAMPLE USAGE
simpleFtpUpload("
ftp://ftp.SOMEWHERE.com/",
"DriveX:Users:YOU:Desktop:TEMP:some'dir:person's ploy", "testme",
"testing12")
on simpleFtpUpload(remoteURL, macFilePath, userName, userPasswd)
-- version 1.1, Dan Shockley (
http://www.danshockley.com)
-- uses curl to do the upload
-- remoteURL is the complete ftp url to the remote
destination directory
if userName is "" then
set userName to "anonymous"
set userPasswd to "email@hidden"
-- no email address, change if desired
end if
-- get parentFolder
if (macFilePath as string) ends with ":" then -- it is a folder itself
set {od, AppleScript's text item delimiters} to
{AppleScript's text item delimiters, ":"}
set parentFolder to (text items 1 thru -3 of
(macFilePath as string)) as string
set AppleScript's text item delimiters to od
else -- it is just a file
set {od, AppleScript's text item delimiters} to
{AppleScript's text item delimiters, ":"}
set parentFolder to (text items 1 thru -2 of
(macFilePath as string)) as string
set AppleScript's text item delimiters to od
end if
set localPosixPath to quoted form of POSIX path of alias macFilePath
set uploadFileName to do shell script "basename " & localPosixPath
set uploadDirectory to quoted form of POSIX path of parentFolder
-- curl --upload-file SOMEFILE
ftp://SERVER.com --user MYUSER:THEPASSWD
-- must be IN the directory of the file you want to upload
set myCommand to "cd " & uploadDirectory & ";" & "curl
--upload-file " & quoted form of uploadFileName ,
& " " & remoteURL & " --user " & userName & ":" &
userPasswd & ,
" " & "--write-out " & "%{size_upload}" & " --quote -quit"
-- output is the 'size_upload' result from curl
log myCommand
set uploadResult to do shell script myCommand
return uploadResult -- size uploaded in kilobytes
end simpleFtpUpload
--
----
Daniel A. Shockley
email@hidden
email@hidden
http://www.danshockley.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.