Vbscript and ftp...

If you touch your software enough does it become hardware?

Moderator: Forum Moderators

Post Reply
amblin
Zombie Spanger
Zombie Spanger
Posts: 2663
Joined: October 22nd, 2004, 11:50

Vbscript and ftp...

Post by amblin »

.
Last edited by amblin on May 6th, 2014, 11:32, edited 1 time in total.
Fear
Zombie
Zombie
Posts: 2032
Joined: August 6th, 2006, 21:45

Post 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.
amblin
Zombie Spanger
Zombie Spanger
Posts: 2663
Joined: October 22nd, 2004, 11:50

Post by amblin »

.
Last edited by amblin on May 6th, 2014, 11:32, edited 1 time in total.
Fear
Zombie
Zombie
Posts: 2032
Joined: August 6th, 2006, 21:45

Post 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:

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

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
Zombie Spanger
Zombie Spanger
Posts: 2663
Joined: October 22nd, 2004, 11:50

Post by amblin »

.
Last edited by amblin on May 6th, 2014, 11:32, edited 1 time in total.
Fear
Zombie
Zombie
Posts: 2032
Joined: August 6th, 2006, 21:45

Post 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
Woo Elephant Yeah
Heavy
Heavy
Posts: 5433
Joined: October 10th, 2004, 17:36
Location: Bristol, UK
Contact:

Post by Woo Elephant Yeah »

I knight Fear as "5punks Official Techy Nerd"

*5punks on each shoulder*
*finishes with a money shot on the forehead*
Fear
Zombie
Zombie
Posts: 2032
Joined: August 6th, 2006, 21:45

Post by Fear »

*Towels off*

*Rises*
Post Reply