Copying file to many destination and one log file.

Advertisement

(elmo)
Joined:
Posts:
3

Copying file to many destination and one log file.

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
open %1% -hostkey=*
cd /var/tmp 
option transfer binary
put c:/winscp/example.txt 
close
exit

run1.bat 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
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
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.

Reply with quote

Advertisement

(elmo)

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.

Reply with quote

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

To append an output to a file in the batch file, use >>:
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:
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

Reply with quote

(elmo)
Joined:
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?

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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,506
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.
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".

Reply with quote

Advertisement

You can post new topics in this forum