Tcl
Tcl
Send an FTP NOOP (Keep-Alive)
See more FTP Examples
Demonstrates the Chilkat Ftp2.Noop method, which sends the FTP NOOP command. It takes no arguments and succeeds only when the server returns a positive reply.
Background:
NOOP asks the server to do nothing and simply reply, which makes it the standard keep-alive: sending one periodically resets the server's idle timer so a long-running job does not lose its control connection between transfers. Because it exercises a real request/reply round trip, a successful NOOP is also firmer evidence the connection is alive than CheckConnection.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# Demonstrates the Ftp2.Noop method, which sends the FTP NOOP command. It takes no arguments.
# The server must return a positive reply for the method to succeed.
set ftp [new_CkFtp2]
CkFtp2_put_Hostname $ftp "ftp.example.com"
CkFtp2_put_Username $ftp "myFtpLogin"
# Normally you would not hard-code the password in source. You should instead obtain it
# from an interactive prompt, environment variable, or a secrets vault.
CkFtp2_put_Password $ftp "myPassword"
# Connect and log in (Connect performs both).
set success [CkFtp2_Connect $ftp]
if {$success == 0} then {
puts [CkFtp2_lastErrorText $ftp]
delete_CkFtp2 $ftp
exit
}
# NOOP does nothing on the server, but a successful reply confirms the control connection is
# still responsive -- useful as a keep-alive during an otherwise idle session.
set success [CkFtp2_Noop $ftp]
if {$success == 0} then {
puts [CkFtp2_lastErrorText $ftp]
delete_CkFtp2 $ftp
exit
}
puts "NOOP acknowledged by the server."
set success [CkFtp2_Disconnect $ftp]
if {$success == 0} then {
puts [CkFtp2_lastErrorText $ftp]
delete_CkFtp2 $ftp
exit
}
delete_CkFtp2 $ftp