Page 1 of 1
Vbscript and ftp...
Posted: November 7th, 2006, 12:43
by amblin
.
Posted: November 7th, 2006, 13:06
by Fear
Do you mean VBA? VBA is access/excel/etc - VBScript is Windows Scripting Host.
I've got some scripts about I can dig out, tho let me know which flavour.
Posted: November 7th, 2006, 13:29
by amblin
.
Posted: November 7th, 2006, 14:12
by Fear
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.
Code: Select all
open ftp.microsoft.com
anonymous
guest
ascii
get dirmap.txt
quit
Then to run this file:
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
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.
Posted: November 7th, 2006, 15:37
by amblin
.
Posted: November 7th, 2006, 15:55
by Fear
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
Do the file creation in a module.
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
Posted: November 7th, 2006, 17:41
by Woo Elephant Yeah
I knight Fear as "5punks Official Techy Nerd"
*5punks on each shoulder*
*finishes with a money shot on the forehead*
Posted: November 7th, 2006, 18:58
by Fear
*Towels off*
*Rises*