Re: ftp in terminal...
Re: ftp in terminal...
- Subject: Re: ftp in terminal...
- From: Stefan Eriksson <email@hidden>
- Date: Sun, 17 Apr 2005 00:39:56 +0200
Since no-one is answering my prayers i´ll guess i have to do all the work myself.. ;)
found this piece of code when looking around and it really works as a charm !
Link to site is http://danshockley.com/codebits.php#simpleFTPupload
Have a great weekend, Stefan
simpleFTPupload
<x-tad-smaller> The is a simple curl replacement for the URL Access Scripting FTP upload capability.
</x-tad-smaller><x-tad-smaller>-- 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.2, Dan Shockley (http://www.danshockley.com)
-- uses curl to do the upload
-- remoteURL is the complete ftp url to the remote destination directory
try
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 "
set myCommand to myCommand & quoted form of uploadFileName
set myCommand to myCommand & " " & remoteURL
set myCommand to myCommand & " --user " & userName & ":" & userPasswd
set myCommand to myCommand & " " & "--write-out " & "%{size_upload}"
set myCommand to myCommand & " --quote -quit"
-- output is the 'size_upload' result from curl
set uploadResult to do shell script myCommand
return uploadResult -- size uploaded in kilobytes
on error errMsg number errNum
error "simpleFtpUpload FAILED: " & errMsg number errNum
end try
end simpleFtpUpload</x-tad-smaller> _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden