Batch Command "put" not working

Advertisement

jdombrowski
Joined:
Posts:
1

Batch Command "put" not working

Having an issue putting a file. I have everything connecting with the command, and I can drag/drop the file using the GUI.

Here is my command:
WinSCP.exe /log=c:\localfolder\winscp.log /command -open sftp://[user]:[pass]@ftp.server.com:9922/ -hostkey="ssh-rsa 2048 ho:st:ke:yy" -put "C:\Localfolder\file.csv /" "exit"
I've also tried with put C:\localfolder\file.csv /. And not having the / for the put command. Same thing happens, it skips the put command.

Here is the relevant part of the log (after the SSH and ssh key connection):
. 2018-01-15 11:27:12.883 Access granted
. 2018-01-15 11:27:12.883 Opening session as main channel
. 2018-01-15 11:27:12.945 Opened main channel
. 2018-01-15 11:27:13.102 Started a shell/command
. 2018-01-15 11:27:13.102 --------------------------------------------------------------------------
. 2018-01-15 11:27:13.102 Using SFTP protocol.
. 2018-01-15 11:27:13.102 Doing startup conversation with host.
> 2018-01-15 11:27:13.102 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2018-01-15 11:27:13.164 Type: SSH_FXP_VERSION, Size: 124, Number: -1
. 2018-01-15 11:27:13.164 SFTP version 3 negotiated.
. 2018-01-15 11:27:13.164 Unknown server extension posix-rename@openssh.com="1"
. 2018-01-15 11:27:13.164 Supports statvfs@openssh.com extension version "2"
. 2018-01-15 11:27:13.164 Unknown server extension fstatvfs@openssh.com="2"
. 2018-01-15 11:27:13.164 Supports hardlink@openssh.com extension version "1"
. 2018-01-15 11:27:13.164 We believe the server has signed timestamps bug
. 2018-01-15 11:27:13.164 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 strings are not mandatory
. 2018-01-15 11:27:13.164 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2018-01-15 11:27:13.164 Getting current directory name.
. 2018-01-15 11:27:13.164 Getting real path for '.'
> 2018-01-15 11:27:13.164 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2018-01-15 11:27:13.242 Type: SSH_FXP_NAME, Size: 51, Number: 16
. 2018-01-15 11:27:13.242 Real path is '/home/folder'
. 2018-01-15 11:27:13.242 Startup conversation with host finished.
< 2018-01-15 11:27:13.242 Script: Active session: [1] user@ftp.server.com:9922
. 2018-01-15 11:27:13.242 Script: Exit code: 0
. 2018-01-15 11:27:13.242 Closing connection.
. 2018-01-15 11:27:13.242 Sending special code: 12
. 2018-01-15 11:27:13.242 Sent EOF message
You can see that I get "Active Session", then the exit code.

Any help is appreciated.

John Dombrowski

Reply with quote

Advertisement

Robin.Kusch63
Guest

Command put not working

Try to get and put files from and to a remote Server. Command get works fine (executing with a .bat file). Command put no way. Here is my .bat script: Could someone help me?
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="E:\Transfer\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://zArvRxB5BSyc:fH%%21QvEVGPGzvnvK%%25@217.6.xxx.xxx/ -hostkey=""xxxxx-sha2-xxxxx256 256 rrx6njGsiGNuFRbcLxxxxx2a2Pcos42sjXgcHPqH/Bs=""" ^
    "lcd E:\Transfer\READYFORUPLOAD" ^
    "cd /home/zArvRxB5BSyc/datapack" ^
    "put 4048695000000_StockFile_20211019124659.txt" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
36,472
Location:
Prague, Czechia

Re: Command put not working

@Robin.Kusch63: 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