Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Script to upload folders or files does not work

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=C:\path\to\winscp.log command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
diaverso

Script to upload folders or files does not work

Have created with the program generator 2 scripts.

1st
@echo off
 
"C:\Users\SUPER\AppData\Local\Programs\WinSCP\WinSCP.com" ^
  /log="C:\ruta\editable\al\registro\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://diaverso.5633997f:pass@ip:2022/ -hostkey="""" -rawsettings FSProtocol=2" ^
    "put D:\Scripts\FTP\myscript.txt /" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%

I get this result in the console, but it doesn't sync the folder


2nd
## Necesario para PowerShell 7.3 y posteriores
$PSNativeCommandArgumentPassing = "Legacy"
 
& "C:\Users\SUPER\AppData\Local\Programs\WinSCP\WinSCP.com" `
  /log="C:\Users\SUPER\AppData\Local\Programs\WinSCP\logWinSCP.log" /ini=nul `
  /command `
    "open sftp://diaverso.5633997f:pass@ip:2022/ -hostkey=`"`"ssh-ed25519 `"`" -rawsettings FSProtocol=2" `
    "put D:\Scripts\FTP\myscript.txt /" `
    "Su orden 2" `
    "exit"
 
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
  Write-Host "Success"
}
else
{
  Write-Host "Error"
}
 
exit $winscpResult

This comes out, but it doesn't upload the file


How can I fix it?