Differences
This shows you the differences between the selected revisions of the page.
script_upload_file_list 2017-02-16 | script_upload_file_list 2022-06-16 (current) | ||
Line 16: | Line 16: | ||
UserName = "user" | UserName = "user" | ||
Password = "mypassword" | Password = "mypassword" | ||
- | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
} | } | ||
Line 32: | Line 32: | ||
foreach ($line in $lines) | foreach ($line in $lines) | ||
{ | { | ||
- | Write-Host ("Uploading {0} ..." -f $line) | + | Write-Host "Uploading $line ..." |
$session.PutFiles($line, $remotePath).Check() | $session.PutFiles($line, $remotePath).Check() | ||
} | } | ||
Line 44: | Line 44: | ||
exit 0 | exit 0 | ||
} | } | ||
- | catch [Exception] | + | catch |
{ | { | ||
- | Write-Host ("Error: {0}" -f $_.Exception.Message) | + | Write-Host "Error: $($_.Exception.Message)" |
exit 1 | exit 1 | ||
} | } | ||
Line 52: | Line 52: | ||
===== [[scripting]] Using WinSCP Scripting ===== | ===== [[scripting]] Using WinSCP Scripting ===== | ||
- | You may use following batch file that calls WinSCP [[scripting|script]]: | + | You may use following batch file that calls generated WinSCP [[scripting|script]]: |
<code batch> | <code batch> | ||
@echo off | @echo off | ||
- | set SESSION=sftp://user:password@example.com/ | + | set SESSION=sftp://user:password;fingerprint=ssh-rsa-xxxxxxxxxxx...@example.com/ |
set REMOTE_PATH=/home/user/ | set REMOTE_PATH=/home/user/ | ||
- | echo open %SESSION% >> script.tmp | + | ( |
+ | ··echo open %SESSION% | ||
+ | echo <nohilite>cd</nohilite> %REMOTE_PATH% | ||
- | rem Generate "put" command for each line in list file | + | ··rem Generate "put" command for each line in list file |
- | for /F %%i in (list.txt) do echo put "%%i" "%REMOTE_PATH%" >> script.tmp | + | ··for /F %%i in (list.txt) do echo put "%%i" |
- | echo exit·>> script.tmp | + | ··echo <nohilite>exit</nohilite> |
+ | ) > script.tmp | ||
- | winscp.com /script=script.tmp | + | winscp.com /ini=nul /log=script.log /script=script.tmp |
set RESULT=%ERRORLEVEL% | set RESULT=%ERRORLEVEL% | ||