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.