-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftp_down
59 lines (47 loc) · 1.34 KB
/
ftp_down
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
integer li_rc
oleobject loo_Ftp
integer li_Success
string ls_LocalFilename
string ls_RemoteFilename
// 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_9_5_0.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"
// Use passive mode:
loo_Ftp.Passive = 1
// 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
// Change to the remote directory where the file is located.
// This step is only necessary if the file is not in the root directory
// for the FTP account.
li_Success = loo_Ftp.ChangeRemoteDir("junk")
if li_Success <> 1 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
// Download a file.
ls_LocalFilename = "hamlet.xml"
ls_RemoteFilename = "hamlet.xml"
li_Success = loo_Ftp.GetFile(ls_RemoteFilename,ls_LocalFilename)
if li_Success <> 1 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
li_Success = loo_Ftp.Disconnect()
Write-Debug "File Downloaded!"
destroy loo_Ftp