Topic "Copying file to many destination and one log file."

Author Message
(elmo)
[View user's profile]

Joined: 2017-10-25
Posts: 3
Hi All

I have created run.bat file that is using script.
Main goal that i want to achieve is to send one file to many hosts and verify gather log that will be proof that transfer was succeed for all of them, or in case of failure I will be able to verify which one doesn't get file.

script.txt
Code:
open %1% -hostkey=*
cd /var/tmp
option transfer binary
put c:/winscp/example.txt
close
exit


run1.bat code
Code:
winscp.com  /script=script.txt /parameter user:password@host1 /log=mylog.txt
winscp.com  /script=script.txt /parameter user:password@host2 /log=mylog.txt
winscp.com  /script=script.txt /parameter user:password@host3 /log=mylog.txt


run2.bat code
Code:
winscp.com  /script=script.txt /parameter user:password@host1 /log=mylog.txt>output.txt
winscp.com  /script=script.txt /parameter user:password@host2 /log=mylog.txt>output.txt
winscp.com  /script=script.txt /parameter user:password@host3 /log=mylog.txt>output.txt


run3.bat code
Code:
winscp.com  /script=script.txt /parameter user:password@host1 /log=mylog.xml
winscp.com  /script=script.txt /parameter user:password@host2 /log=mylog.xml
winscp.com  /script=script.txt /parameter user:password@host3 /log=mylog.xml


When I start run1.bat i get proper mylog.txt but very long with redundant information, file is difficult to analyze
When I start run2.bat output.txt contain only host3 log
When I start run3.bat mylog.xml contain only host3 log

What should I do to get whole log like with run1.bat but in txt format or xml format.
Please give me some hint.

Thanks in advance.
Advertisements
(elmo)
[View user's profile]

Joined: 2017-10-25
Posts: 3
Maybe there is option to make xml file additive?
I saw that for window version, there is option "Append" that caused adding log at the end of existing one.
Is there anybody who know how to force console to use that option.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
To append an output to a file in the batch file, use >>:
Code:
winscp.com  /script=script.txt /parameter user:password@host1 /log=mylog.txt > output.txt
winscp.com  /script=script.txt /parameter user:password@host2 /log=mylog.txt >> output.txt
winscp.com  /script=script.txt /parameter user:password@host3 /log=mylog.txt >> output.txt

You can also make XML log file name unique by using a pattern like !S-!Y!M!D!T:
Code:
winscp.com  /script=script.txt /parameter user:password@host1 /log=mylog-!S-!Y!M!D!T.xml

See https://winscp.net/eng/docs/ui_pref_logging#session_log
(elmo)
[View user's profile]

Joined: 2017-10-25
Posts: 3
Hi Martin

Below script works fine.
Is there any other option to get continuous xml log? Any idea how to redirect this long mylog.txt or output.txt to xml?

Code:
winscp.com  /script=script.txt /parameter user:password@host1 /log=mylog.txt > output.txt
winscp.com  /script=script.txt /parameter user:password@host2 /log=mylog.txt >> output.txt
winscp.com  /script=script.txt /parameter user:password@host3 /log=mylog.txt >> output.txt
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
(elmo) wrote:
Is there any other option to get continuous xml log?

You can merge them. E.g. using XSLT, it should be rather easy.
Quote:
Any idea how to redirect this long mylog.txt or output.txt to xml?

I do not understand what you mean by "redirect to XML".
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License