Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp

li_Success = 0

//  Demonstrates the Ftp2.Site method, which sends a server-specific SITE command.  The only
//  argument is the text following "SITE".

loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
    destroy loo_Ftp
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Ftp.Hostname = "ftp.example.com"
loo_Ftp.Username = "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.
loo_Ftp.Password = "myPassword"

//  Connect and log in (Connect performs both).
li_Success = loo_Ftp.Connect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

//  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.
li_Success = loo_Ftp.Site("CHMOD 644 public_html/index.html")
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

Write-Debug "SITE command accepted."

li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if



destroy loo_Ftp