home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Demo / PCDUO / data1.cab / Script_Samples / XCOPY.SCP < prev   
Encoding:
Text File  |  2003-11-28  |  2.2 KB  |  73 lines

  1. // XCopy.SCP Sample Script to show the new XCopy function
  2. // Copyright (c) 2000, Vector Networks Limited
  3. // All Rights Reserved
  4. //
  5. // Revision History:
  6. // 0.0 16-Jun-00 DB - Created.
  7.  
  8. //  The Script attempts to connect to the Client named in variable Client, 
  9. //  using the username (and encrypted password) in variable Username.
  10. //  Having made the connection, we try to copy the directory Source 
  11. //  into directory Destination. 
  12. //
  13. //  If FileSpec is non-null, it provides a wildcard to match files in the Source 
  14. //  directory.
  15. //
  16. // Script requirements:-
  17. //  Predefined variables:
  18. //    Client   = "TEST"
  19. //    Username = "USER/GBBLLYDGKK"
  20. //    Source = "C:\TEMP"
  21. //    FileSpec = "*.*"
  22. //    Destination = ">C:\"
  23.  
  24. Function Main ()
  25. Dim Client as String, Username as String
  26. Dim Source as String, FileSpec as String
  27. Dim Destination as String, Path as String
  28. Dim Status as Integer
  29.  
  30.     SetTransport (T_TCPIP)
  31.  
  32.     If Connect (Client, Username) = TRUE Then 
  33.         Print "Connected to Client ", Client
  34.  
  35.         If Trim (Source) = "" then
  36.             Print "No files to transfer!"
  37.         Else
  38.  
  39.             //  Handle an empty (wildcard) FileSpec
  40.  
  41.             If Trim (FileSpec) = "" then
  42.                 FileSpec = "*.*"
  43.             Endif
  44.  
  45.             //  Now, we have the complete source filespec
  46.  
  47.             Path = Source + "\" + FileSpec
  48.  
  49.             //  Handle an empty (default) destination
  50.  
  51.             If Trim (Destination) = "" then
  52.  
  53.                 //  Find the transfer direction. Look for an ">" 
  54.                 //  in Path, as we can only copy files between 
  55.                 //  Control and Client, one or other location
  56.                 //  must be on the Client.
  57.  
  58.                 If InStr (Path, ">") = 0 then
  59.                     Destination = ">C:\"
  60.                 Else
  61.                     Destination = "C:\"
  62.                 Endif
  63.             Endif
  64.             Print "Starting file transfer from ", Path, " to ", Destination
  65.             Status = XCopy (Path, Destination)
  66.             Print "Transfer status = ", Status
  67.         Endif
  68.         Wait (2)
  69.         Print "Disconnecting..."
  70.         Disconnect (Client)
  71.     EndIf
  72. End Function
  73.