Artifact
b2cdd6d3a66aa9a7022427fa098d01fa3711d01f:
Attachment "ftp-code-sample.tcl" to
ticket [3610022fff]
added by
guitarzar
2013-04-04 23:17:13.
set remIp 1.1.1.1
set user test
set passwd test123
set files [ list of files that is created dynamically via files on the local machine ]
set remFtpPath destPath
while {1} {
puts "Connecting to $remIp ..."
if { [ set fh [ ftp::Open $remIp $user $passwd -timeout 120 ] ] != -1 } {
puts "Cd'ing to $remFtpPath ..."
set response [ ftp::Cd $fh $remFtpPath ]
if { $response } {
puts "Gathering bin file list from $remIp ..."
set rfiles [ ftp::List $fh *.bin ]
}
foreach rfile $rfiles {
lappend images [ lindex $rfile end ]
}
puts "IMAGES: $images"
foreach file $files {
if { [ lsearch -exact $images $file ] < 0 } {
puts -nonewline "Copying $file to $remFtpPath on $remIp ... "
flush stdout
# Copy files to target dir
if { [ ftp::Put $fh $file ] } {
puts "succeeded"
} else {
puts "failed"
}
}
}
ftp::Close $fh
}
after 60000
}