Script to upload folders or files does not work

Advertisement

diaverso
Joined:
Posts:
1
Location:
spain

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?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,605
Location:
Prague, Czechia

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.

Reply with quote

Advertisement

You can post new topics in this forum