Tcl
Tcl
Send an FTP SITE Command
See more FTP Examples
Demonstrates the Chilkat Ftp2.Site method, which sends a server-specific SITE command. The only argument is the text following SITE, for example CHMOD 644 index.html.
Background:
SITE is FTP's extension point for features outside the standard — each server defines its own subcommands. The best-known is SITE CHMOD on Unix servers to set file permissions, but others cover mainframe dataset attributes, quotas, and more. Because these are non-standard and often privileged, expect them to vary by server and to require appropriate rights.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# Demonstrates the Ftp2.Site method, which sends a server-specific SITE command. The only
# argument is the text following "SITE".
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
}
# SITE subcommands are defined by the server, not by the FTP standard, and may require special
# permissions. A common example is changing file permissions on a Unix FTP server.
set success [CkFtp2_Site $ftp "CHMOD 644 public_html/index.html"]
if {$success == 0} then {
puts [CkFtp2_lastErrorText $ftp]
delete_CkFtp2 $ftp
exit
}
puts "SITE command accepted."
set success [CkFtp2_Disconnect $ftp]
if {$success == 0} then {
puts [CkFtp2_lastErrorText $ftp]
delete_CkFtp2 $ftp
exit
}
delete_CkFtp2 $ftp