Synchronizing local folder script

Advertisement

jland47
Joined:
Posts:
4
Location:
LA

Synchronizing local folder script

Been reading multiple post on this topic and still not 100% on how to go about this. I copied this script from another post. Do I just save this as a .bat and I can run it? Ultimate goal is to be able to schedule the script through task scheduler to run at a set time each day. The next hurdle is the script, does this look ok? I don't know if I have the /log statement correct, does this just create a log, do I really need it?
"C:\Program Files (x86)\WinSCP\winscp.com" /log="C:\Program Files (x86)\WinSCP\test\winscp.log" /command ^
   "option batch abort" ^"open ftp://user@###.###.##.###:password@###.###.##.###/Action" ^
   "synchronize remote "O:\Purchase Orders\z-POs\Automated_PO\Lapco_PO\PO_*" /Action" ^
   "exit"
pause

Reply with quote

Advertisement

jland47
Joined:
Posts:
4
Location:
LA

Should something be in front of the code? When I run it as a .bat the whole first section of code looks like it is just printed on the command screen and is not "doing" anything. After the first "exit" command I get these lines of code;
Error occurred during logging. It's been turned off.
Can't open log file 'C:\Program Files (x86)\WinSCP\test\winscp.log'.
System Error.  Code: 5.
Access is denied
Connecting to ###.###.##.### ...
Connected
Starting the session...
Session started.
Active session: [1] user@###.###.##.###
Then this is the last part
C:\Users\jarett.AS\Documents>set WINSCP_RESULT=1

C:\Users\jarett.AS\Documents>if 1 EQU 0 (echo Success )  else (echo Error )
Erro

Reply with quote

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

You need to log to a folder, where you have write permissions. So definitely not to the Program Files.

I've now notices that you have the synchronize command wrong. It should be like:
   "synchronize remote ""O:\Purchase Orders\z-POs\Automated_PO\Lapco_PO\PO_*"" /Action" ^
See https://winscp.net/eng/docs/commandline#syntax

Reply with quote

jland47
Joined:
Posts:
4
Location:
LA

I got my scripts to work the bat script
"C:\Program Files (x86)\WinSCP\WinSCP.com" /script=C:\Users\jarett.AS\Documents\lapcosync.txt

With the text script
option batch abort
option confirm off
open ftp://user:pass!@ip/ -passive=off
synchronize remote "O:\Purchase Orders\z-POs\Automated_PO\Lapco_PO" /Action 
exit

I am still confused on the log part, I've read the section on logging but it's not clicking in my head.

Reply with quote

Advertisement

jland47

Do you put the /log command in the bat or text file? Do you create a folder for it or do you just point to which drive you want it to go to ex. C:\DOCUMENTS\? What type of file extension is it, the example I was looking at had a .log extension is this correct?

Reply with quote

martin
Site Admin
martin avatar

You put the /log on the WinSCP commandline. Just as you have it in your very first post.
The target folder must exists. The path must a be full file path, not just the target directory. Again, just as you have it in your first post. Though there you obviously have problem with C:\Program Files (x86) not being a writable folder. You have to point WinSCP to a folder, where you have write permissions to. The extension does not really matter (it just cannot be .xml).

Reply with quote

Advertisement

You can post new topics in this forum