Vbscript and ftp...
Moderator: Forum Moderators
The best solution I can find is this:
Create a file named ftpcmds.txt (for example). In this file each line represents a command to run, in sequence.
Then to run this file:
More specific to you would be:
The text file would have to be generated in vba (I can give examples if you need), then the vba code would run the ftp session. From memory the vba command you need is .
I can't think of an easy way to test if the file is there other than downloading it, and either comaparing file's size or by generating a chksum. Otherwise you have no way of knowing if the file on the server is not corrupt. chksum is the prefered method here. I don't think VBA has any cryptographic functions tho unless they have merged it with .net in recent versions. Sure the internet would provide a solution or me (or another 5punker) could if you get stuck.
Summary
1. Generate put FTP commands file
2. Run FTP shell
3. Generate get FTP commands file
4. Run FTP shell
5. Compare files and return status.
Create a file named ftpcmds.txt (for example). In this file each line represents a command to run, in sequence.
Code: Select all
open ftp.microsoft.com
anonymous
guest
ascii
get dirmap.txt
quit
Code: Select all
ftp -s:ftpcmds.txt
More specific to you would be:
Code: Select all
open 1.2.3.4
username
password
ascii <- set this to binary if files contain non-ascii chars
put yourfile.001 yourfile.001
quit
Code: Select all
shell commandname
I can't think of an easy way to test if the file is there other than downloading it, and either comaparing file's size or by generating a chksum. Otherwise you have no way of knowing if the file on the server is not corrupt. chksum is the prefered method here. I don't think VBA has any cryptographic functions tho unless they have merged it with .net in recent versions. Sure the internet would provide a solution or me (or another 5punker) could if you get stuck.
Summary
1. Generate put FTP commands file
2. Run FTP shell
3. Generate get FTP commands file
4. Run FTP shell
5. Compare files and return status.
amblin wrote:but can it be driven from an access table?
Code: Select all
Open "C:\myFile.txt" For Output as #1
Print #1, "something"
Print #1, "something else"
Close #1
A simple access of a table in code is, looping through each row:
Code: Select all
Dim dbs as Database = CurrentDB
Dim myRecordSet As Recordset
Dim myString as String
Set myRecordSet = dbs.OpenRecordset("YourTableOrQuery", dbOpenDynaset)
With myRecordSet
If Not .EOF Then
Do While True
myString &= !YourFieldName & ","
rst.MoveNext
If myRecordSet.EOF = True Then
Exit Do
End If
Loop
Else
MsgBox "No records"
End If
End With
myRecordSet.Close
Set myRecordSet = Nothing
-
- Heavy
- Posts: 5433
- Joined: October 10th, 2004, 17:36
- Location: Bristol, UK
- Contact: