PowerBuilder
PowerBuilder
Quote and SendCommand
See more FTP Examples
Demonstrate the Quote and SendCommand methods.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Ftp
string ls_ServerResponse
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
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 = "login"
loo_Ftp.Password = "password"
// Connect and login to the FTP server.
li_Success = loo_Ftp.Connect()
if li_Success <> 1 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
// Tell the FTP object to keep an in-memory session log
// so we can see the commands sent to the server,
// and the responses received back.
loo_Ftp.KeepSessionLog = 1
// Change the current remote directory via the Quote method:
li_Success = loo_Ftp.Quote("CWD junk")
if li_Success <> 1 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
// Move back up
// In this case, ChangeRemoteDir sends "CWD .." to the FTP server.
li_Success = loo_Ftp.ChangeRemoteDir("..")
if li_Success <> 1 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
// Do the same via the SendCommand method where the
// raw FTP server response is returned:
ls_ServerResponse = loo_Ftp.SendCommand("CWD junk")
if loo_Ftp.LastMethodSuccess <> 1 then
Write-Debug loo_Ftp.LastErrorText
else
Write-Debug ls_ServerResponse
end if
li_Success = loo_Ftp.Disconnect()
Write-Debug "Session Log:"
Write-Debug loo_Ftp.SessionLog
destroy loo_Ftp