• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: FTP Upload
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FTP Upload


  • Subject: Re: FTP Upload
  • From: Björn Lundin <email@hidden>
  • Date: Sat, 28 Jan 2006 16:22:17 +0100

28 jan 2006 kl. 11.44 skrev Alexander Thiel:

Hi everyone,

I try to do a folder action, which uploads every file to a ftp-server, even if the files are in nested folders, after upload the files should be deleted. I did several tests with "URL Access Scripting", and with "curl" but I wasn't succesfull :( 

Could you give me hint, how I could handle this?

I'd do it with Expect, but other people will proberbly use your approach:

if you can 'do shell script' this, from a folderaction,
giving the script it's input parameters, you're basically done

######
#!/usr/bin/expect

proc Autoput { Username Password Ftp_Server Remote_Directory Local_Directory} {
  global timeout
  set timeout 5
  spawn ftp $Ftp_Server
 
  expect  {
             "Name*:"   {send "$Username\r"}
             timeout    {exit 1 }
          }   
  expect  {
             "*ssword:" {send "$Password\r"}
             timeout    {exit 1 }
          }
   expect {
             "ftp>"     {send "binary\r"}
             timeout    {exit 1 }
          }
   expect {
             "ftp>"     {send "cd $Remote_Directory\r"}
             timeout    {exit 1 }
          }
   expect {
             "ftp>"     {}
             timeout    {exit 1 }
          }

   set timeout 600
   set Filelist [glob -nocomplain * ]

   cd $Local_Directory
   foreach Potential_File $Filelist {
      if {[file isdirectory $Potential_File]} {
        cd $Potential_File
      } else {
        send "put $Potential_File\r"  
        expect {
                 "ftp>"     {file delete $Potential_File}
                 timeout    {exit 1 }
               }
      }
    }
    send "bye\r"
    expect eof
}

#Usage
#Autoput Username Password Ftp_Server Remote_Directory Local_Directory
Autoput [lindex $argv 0] \
        [lindex $argv 1] \
        [lindex $argv 2] \
        [lindex $argv 3] \
        [lindex $argv 4]


###### 


I think Expect comes with osx, I don't think I installed it afterwards.


--do shell script "curl -t " & this_item & "'ftp_connection'"

I think you wan't CAPITAL t here. But as I interpret the 'man curl' it's aimed towards PUT on http servers, NOT ftp servers


don't forget to make the expect script executable ( Terminal => chmod a+x autoput.tcl
if that's the name of the script.



/Björn


Björn Lundin

bnl at spray dot se



Attachment: PGP.sig
Description: This is a digitally signed message part

 _______________________________________________
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

  • Follow-Ups:
    • Re: FTP Upload
      • From: Björn Lundin <email@hidden>
References: 
 >FTP Upload (From: Alexander Thiel <email@hidden>)

  • Prev by Date: Re: choose folder (was: Tell Statement Problem)
  • Next by Date: Re: FTP Upload
  • Previous by thread: Re: FTP Upload
  • Next by thread: Re: FTP Upload
  • Index(es):
    • Date
    • Thread