Bjvrn,

   Would a simple UniObjects/VBscript do the job? It could connect to both
   servers and act as a quick and dirty shuttle.

   Something along the lines of :

   Dim sess1,sess2
   Dim HostName1,UserName1,AccountPath1,Password1,FileName1
   Dim HostName2,UserName2,AccountPath2,Password2,FileName2

      HostName1 = "localhost"
      UserName1 = "administrator"
      AccountPath1 = "wychbooks"
      Password1 = InputBox("Password for " & UserName1 & " on " & HostName1)
      FileName1 = "BOOK_SALES"
      IsUniData = False

      HostName2 = "localhost"
      UserName2 = "administrator"
      AccountPath2 = "pick"
      Password2 = InputBox("Password for " & UserName2 & " on " & HostName2)
      FileName2 = "TESTFILE"

   If DoConnections() = False Then
      Msgbox "Could not connect"
   Else
      Msgbox "Connected to server"
      DoCopyFile
   End If

   Function DoConnections()

      If CreateSessions() = False Then
         Msgbox "Could not create sessions"
         DoConnections = False
         Exit Function
      End If

      sess1.HostName = HostName1
      sess1.UserName = UserName1
      sess1.AccountPath = AccountPath1
      sess1.Password = Password1
      If IsUniData Then
         sess1.DatabaseType = 2
      End If

      sess1.Connect
      If sess1.Error <> False Then
         Msgbox "Error returned from connect = " & sess1.Error
         DoConnections = False
         Exit Function
      End If

      sess2.HostName = HostName2
      sess2.UserName = UserName2
      sess2.AccountPath = AccountPath2
      sess2.Password = Password2
      If IsUniData Then
         sess2.DatabaseType = 2
      End If

      sess2.Connect
      If sess2.Error <> False Then
         Msgbox "Error returned from connect = " & sess2.Error
         DoConnections = False
         Exit Function
      End If

      DoConnections = True

   End Function

   Function DoCopyFile()
      Dim SourceFL
      Dim TargetFL
      Dim SL

      On Error Resume Next
      Err = False
      Set SourceFL = Sess1.OpenFile(FileName1)
      If (Err <> False) Or (SourceFL IS Nothing) Then
         Msgbox "Could not open " & FileName1
         Exit Function
      End If
      Set TargetFL = Sess2.OpenFile(FileName2)
      If (Err <> False) Or (TargetFL IS Nothing) Then
         Msgbox "Could not open " & FileName2
         Exit Function
      End If
      Set SL = Sess1.SelectList(0)
      SL.Select(SourceFL)
      Do
         SourceFL.RecordId = SL.Next
         SourceFL.Read
         TargetFL.RecordId = SourceFL.RecordId
         TargetFL.Record = SourceFL.Record
         TargetFL.Write
      Loop Until SL.LastRecordRead

      Msgbox "Copy completed"
      DoCopyFile = True

   End Function

   (Dump into notepad, save with a VBS extension and run using CSCRIPT or
   WSCRIPT).

   Brian
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to