Help with Outputlog for mixed scripting

Advertisement

artanyis@...
Guest

Help with Outputlog for mixed scripting

I need help figuring out how to add in an output log for a mixed script.
This is a "Simple" automation to basically pass files from a 3rd party SFTP to a 3rd party software on my clients server. There are several other things going on in the collection of scheduled scripts but what I need help with is getting WinSCP to print the output of the .ini to a log file.

Here is what's inside the .ini:

open User:Pass@Server.location.com
option confirm off
get RootDir:/folder/file D:\OurFolder\SubFolder\
get RootDir:/folder/file2 D:\OurFolder\SubFolder\
exit

The .ini is run from a batch file, here's the line that runs the .ini:

D:\OurFolder\winscp\winscp.exe /script=D:\OurFolder\Get-Files.ini

There are actually 2 other .ini files, but this is the important one. That's all WinSCP does in this series of scripts. I would like to know if there is a way that I can make it so that it prints everything out to a log?

When I run the commands manually I get:

winscp> open User:Pass@Server.location.com
Searching for host...
Connecting to host...
Authenticating...
Using username "User".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] User:Pass@Server.location.com
winscp> get RootDir:/folder/file D:\OurFolder\SubFolder\
file | 0 B | 0.0 KiB/s | binary | 0%
winscp> get RootDir:/folder/file2 D:\OurFolder\SubFolder\
file2 | 0 B | 0.0 KiB/s | binary | 0%
winscp> exit

If i can get it to dump that same information in a log file, I'll be golden.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: Help with Outputlog for mixed scripting

You need to use winscp.com (not winscp.exe) and redirect its output to a file:
https://winscp.net/eng/docs/executables

D:\OurFolder\winscp\winscp.com /script=D:\OurFolder\Get-Files.ini > D:\OurFolder\output.txt

You may also consider using session logging:
https://winscp.net/eng/docs/logging

Note that you should not name WinSCP scripts .ini. They are not INI configuration files.

Reply with quote

artanyis
Guest

It worked

That is exactly what I was looking for, thank you. I had tried using > to print the results before but it either did absolutely nothing or threw an error, "too many parameters," depending where I used it. Thanks for noticing I needed .com instead of .exe

If not an .ini, is there a particular file type that is recommended? Since .ini is just a plain text configuration format, it made it easy for me to differentiate between the WinSCP scripts, the windows batch scripts, the windows Pwershell scripts and the XML task triggers.

Reply with quote

martin
Site Admin
martin avatar

Re: It worked

There's no specific type. So .txt would be the best as it does not impose any specific format (whereas .ini does).

Reply with quote

Advertisement

You can post new topics in this forum