Differences
This shows you the differences between the selected revisions of the page.
| library_example_check_existence_timestamp 2017-10-03 | library_example_check_existence_timestamp 2022-06-16 (current) | ||
| Line 24: | Line 24: | ||
| UserName = "user", | UserName = "user", | ||
| Password = "mypassword", | Password = "mypassword", | ||
| - | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
| }; | }; | ||
| Line 35: | Line 35: | ||
| string fileName = "export_" + stamp + ".txt"; | string fileName = "export_" + stamp + ".txt"; | ||
| string remotePath = "/home/user/sysbatch/" + fileName; | string remotePath = "/home/user/sysbatch/" + fileName; | ||
| - | string localPath = "d:\\backup\\" + fileName; | + | string localPath = @"d:\backup\" + fileName; |
| // Manual "remote to local" synchronization. | // Manual "remote to local" synchronization. | ||
| Line 50: | Line 50: | ||
| { | { | ||
| Console.WriteLine( | Console.WriteLine( | ||
| - | "File {0} exists, local backup {1} does not", remotePath, localPath); | + | "File {0} exists, local backup {1} does not", |
| + | ···························remotePath, localPath); | ||
| download = true; | download = true; | ||
| } | } | ||
| Line 120: | Line 121: | ||
| .UserName = "user" | .UserName = "user" | ||
| .Password = "mypassword" | .Password = "mypassword" | ||
| - | .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." | + | .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
| End With | End With | ||
| Line 206: | Line 207: | ||
| UserName = "user" | UserName = "user" | ||
| Password = "mypassword" | Password = "mypassword" | ||
| - | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
| } | } | ||
| Line 246: | Line 247: | ||
| { | { | ||
| Write-Host ("File $remotePath as well as local backup $localPath exist, " + | Write-Host ("File $remotePath as well as local backup $localPath exist, " + | ||
| - | "but remote file is newer ($remoteWriteTime) than local backup ($localWriteTime)") | + | "but remote file is newer ($remoteWriteTime) than " + |
| + | "local backup ($localWriteTime)") | ||
| $download = $True | $download = $True | ||
| } | } | ||
| Line 253: | Line 255: | ||
| Write-Host ( | Write-Host ( | ||
| "File $remotePath as well as local backup $localPath exist, " + | "File $remotePath as well as local backup $localPath exist, " + | ||
| - | "but remote file is not newer ($remoteWriteTime) than local backup ($localWriteTime)") | + | "but remote file is not newer ($remoteWriteTime) than " + |
| + | "local backup ($localWriteTime)") | ||
| $download = $False | $download = $False | ||
| } | } | ||
| Line 279: | Line 282: | ||
| exit 0 | exit 0 | ||
| } | } | ||
| - | catch [Exception] | + | catch |
| { | { | ||
| Write-Host "Error: $($_.Exception.Message)" | Write-Host "Error: $($_.Exception.Message)" | ||
| Line 302: | Line 305: | ||
| sessionOptions.UserName = "user"; | sessionOptions.UserName = "user"; | ||
| sessionOptions.Password = "mypassword"; | sessionOptions.Password = "mypassword"; | ||
| - | sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..."; | + | sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."; |
| var session = WScript.CreateObject("WinSCP.Session"); | var session = WScript.CreateObject("WinSCP.Session"); | ||
| Line 328: | Line 331: | ||
| // transferOptions.FileMask = fileName; | // transferOptions.FileMask = fileName; | ||
| // session.SynchronizeDirectories( | // session.SynchronizeDirectories( | ||
| - | // SynchronizationMode_Local, localPath, remotePath, false, false, SynchronizationCriteria_Time, | + | // SynchronizationMode_Local, localPath, remotePath, false, false, |
| - | // transferOptions).Check(); | + | // SynchronizationCriteria_Time, transferOptions).Check(); |
| if (session.FileExists(remotePath)) | if (session.FileExists(remotePath)) | ||
| { | { | ||
| Line 335: | Line 338: | ||
| if (!fs.FileExists(localPath)) | if (!fs.FileExists(localPath)) | ||
| { | { | ||
| - | WScript.Echo("File " + remotePath + " exists, local backup " + localPath + " does not"); | + | WScript.Echo( |
| + | ····················"File " + remotePath + " exists, local backup " + localPath + " does not"); | ||
| download = true; | download = true; | ||
| } | } | ||
| Line 346: | Line 350: | ||
| { | { | ||
| WScript.Echo( | WScript.Echo( | ||
| - | "File " + remotePath + " as well as local backup " + localPath + " exist, " + | + | "File " + remotePath + " as well as local backup " + localPath + |
| - | "but remote file is newer (" + remoteWriteTime + ") than local backup (" + localWriteTime + ")"); | + | " exist, but remote file is newer (" + remoteWriteTime + ") than " + |
| + | "local backup (" + localWriteTime + ")"); | ||
| download = true; | download = true; | ||
| } | } | ||
| Line 353: | Line 358: | ||
| { | { | ||
| WScript.Echo( | WScript.Echo( | ||
| - | "File " + remotePath + " as well as local backup " + localPath + " exist, " + | + | "File " + remotePath + " as well as local backup " + localPath + |
| - | "but remote file is not newer (" + remoteWriteTime + ") than " + | + | ·······················" exist, but remote file is not newer (" + remoteWriteTime + ") than " + |
| - | "local backup local backup (" + localWriteTime + ")"); | + | "local backup (" + localWriteTime + ")"); |
| download = false; | download = false; | ||
| } | } | ||
| Line 408: | Line 413: | ||
| .UserName = "user" | .UserName = "user" | ||
| .Password = "mypassword" | .Password = "mypassword" | ||
| - | .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." | + | .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
| End With | End With | ||
| Line 444: | Line 449: | ||
| ' transferOptions.FileMask = fileName | ' transferOptions.FileMask = fileName | ||
| ' session.SynchronizeDirectories( _ | ' session.SynchronizeDirectories( _ | ||
| - | ' SynchronizationMode_Local, localPath, remotePath, false, false, SynchronizationCriteria_Time, _ | + | ' SynchronizationMode_Local, localPath, remotePath, false, false, _ |
| - | ' transferOptions).Check | + | ' SynchronizationCriteria_Time, transferOptions).Check |
| Dim download, remoteWriteTime, localWriteTime | Dim download, remoteWriteTime, localWriteTime | ||
| Line 460: | Line 465: | ||
| WScript.Echo _ | WScript.Echo _ | ||
| "File " & remotePath & " as well as local backup " & localPath & " exist, " & _ | "File " & remotePath & " as well as local backup " & localPath & " exist, " & _ | ||
| - | "but remote file is newer (" & remoteWriteTime & ") than local backup (" & localWriteTime & ")" | + | "but remote file is newer (" & remoteWriteTime & ") than " & _ |
| + | "local backup (" & localWriteTime & ")" | ||
| download = True | download = True | ||
| Else | Else | ||
| Line 466: | Line 472: | ||
| "File " & remotePath & " as well as local backup " & localPath & " exist, " & _ | "File " & remotePath & " as well as local backup " & localPath & " exist, " & _ | ||
| "but remote file is not newer (" & remoteWriteTime & ") than " & _ | "but remote file is not newer (" & remoteWriteTime & ") than " & _ | ||
| - | "local backup local backup (" & localWriteTime & ")" | + | "local backup (" & localWriteTime & ")" |
| download = False | download = False | ||
| End If | End If | ||