Enabling text file logging for WinSCP script

9.3k views Asked by At

Hi have a WinSCP script to put a file on remote server using SFTP, which is working fine. But I would enable logging to a text file on a local directory.

I have the following script

option batch on
option confirm off

# connect minute session
open sftp://xyz.com:22/ -privatekey=E:\PK\*.ppk

# force binary mode transfer
option transfer ascii

# navigate to mediacom and put file
lcd "E:\export\"
cd /mediacom/testdir
put "CI_Tst.tab"

# disconnect daily session
close

# exit WinScP
exit

Many I know how I can log results of above script to a local file?

1

There are 1 answers

0
Martin Prikryl On BEST ANSWER

To enable logging, use the /log= command-line switch of WinSCP:

winscp.com /script=C:\path\to\script.txt /log=C:\path\to\script.log

You can use patterns like !Y-!M-!D-!T-!P to make the filename unique.
See https://winscp.net/eng/docs/ui_pref_logging#session_log