first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Windows 2000: Code; Windows Scripting Host; WSH; an FTP Script That PUTs Data from ADO

'I wrote this script (Go2FTP.scr) for an entertainment company. 'This is a quick hack since they were not concerned about high security.

Dim objShell Dim objFileSys Dim objOutStream Dim strCnn Dim strWrite Dim cnnADO Dim rsADO

strCnn = "Provider=SQLOLEDB.1;" _ & "Password=unsecured1;" _ & "Persist Security Info=False;" _ & "User ID=rasx;" _ & "Initial Catalog=Schedule;" _ & "Data Source=DB2HACK;"

Set cnnADO = WScript.CreateObject("ADODB.Connection") cnnADO.ConnectionString = strCnn cnnADO.Open Set rsADO = cnnADO.Execute("EXECUTE ListGo2Events", , adCmdText)

Set objFileSys = WScript.CreateObject("Scripting.FileSystemObject") Set objOutStream = objFileSys.CreateTextFile("C:\\Go2FTP.txt")

Do While Not rsADO.EOF strWrite = rsADO.Fields("EventID") _ & "|" & rsADO.Fields("ArtistSummary") _ & "|" & rsADO.Fields("ArtistExtended") _ & "|" & rsADO.Fields("VenueID") _ & "|" & rsADO.Fields("DoorDate") _ & "|" & rsADO.Fields("DoorTime") _ & "|" & rsADO.Fields("EventDate") _ & "|" & rsADO.Fields("EventTime") _ & "|" & rsADO.Fields("GenreID") _ & "|" & rsADO.Fields("genre_name") _ & "|" & rsADO.Fields("AgeRestriction") _ & "|" & rsADO.Fields("SoldOutIndicator") _ & "|" & rsADO.Fields("ChangedToDate") _ & "|" & rsADO.Fields("ChangedToTime") _ & "|" & rsADO.Fields("Canceled") Call objOutStream.WriteLine(strWrite) rsADO.MoveNext Loop

rsADO.Close cnnADO.Close

Set rsADO = Nothing Set cnnADO = Nothing

Set objShell = WScript.CreateObject("WScript.Shell") Call objShell.Run("ftp -n -s:Go2FTP.scr.txt") Set objShell = Nothing

'Note that Go2FTP.scr.txt contains the following: ' open 127.0.0.1 ' user ftploser $pass$word ' ascii ' put C:\\Go2FTP.txt ' close ' open 127.0.0.2 ' user ftploser $pass$word ' ascii ' put C:\\Go2FTP.txt ' bye

mod date: 2001-02-07T00:47:45.000Z