Topic "My script of auto sync is not working"

Author Message
paslechoix
[View user's profile]

Joined: 2016-11-10
Posts: 6
Location: Canada
Hello,

This is what I did:
1. Get connected with the server
2. Go to Session, click on Generate Session URL/Code
3. Under the Script tab, select Batch file as the Format, save it to autosync.bat
4. Using a text editor, replace "Your command 1" with:
"synchronize local \Temp /Distribution/Comp1"
run the bat

Nothing copied to a new empty folder C:\Temp

From the log I can see the connection was set up and the directory was pull out. The last a few lines are:
. 2016-11-14 14:02:52.884 Startup conversation with host finished.
. 2016-11-14 14:03:22.525 Sending dummy command to keep session alive.
> 2016-11-14 14:03:22.525 PWD
< 2016-11-14 14:03:22.525 257 "/Distribution/Comp" is current directory
. 2016-11-14 14:03:51.820 Disconnected from server

My script ends up as below:
Code:
@echo off

"C:\WinSCP\WinSCP.com" ^
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
  /command ^
    "open ftpes://ftpuser:password@sftp.mysite.com/" ^
    "synchronize remote \Temp /Distribution/Comp" ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%


Can anyone help me to fix it please? Thank you very much.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26480
Location: Prague, Czechia
Make sure there are no spaces after all ^'s.
If that does not help, a full session log file.
paslechoix
[View user's profile]

Joined: 2016-11-10
Posts: 6
Location: Canada
Thank you.

I removed all spaces after the symbol ^

I ran it again and this time even the WinSCP was not brought up, therefore there is no log I can provide you.

I confirmed by manually started WinSCP and was able to connect, so there is problem with WinSCP.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26480
Location: Prague, Czechia
There has to be some error message. What do you see in the console, when you execute the batch file? Make sure you execute the batch file in console. Not by double-clicking it in Windows Explorer.
paslechoix
[View user's profile]

Joined: 2016-11-10
Posts: 6
Location: Canada
martin wrote:
There has to be some error message. What do you see in the console, when you execute the batch file? Make sure you execute the batch file in console. Not by double-clicking it in Windows Explorer.


Thank you. I ran it from command line and it prompts the first line is not a recognized command:
"open ftpes://ftpuser:password@sftp.mysite.com/" ^

Thank you
Guest




paslechoix wrote:
martin wrote:
There has to be some error message. What do you see in the console, when you execute the batch file? Make sure you execute the batch file in console. Not by double-clicking it in Windows Explorer.


Thank you. I ran it from command line and it prompts the first line is not a recognized command:
"open ftpes://ftpuser:password@sftp.mysite.com/" ^

Thank you


I made some modification to the .bat script but still not working:

"C:\WinSCP\WinSCP.exe /log="C:\SFTP\log\t4log_!Y_!M_!D_!T.log" /loglevel=0 /ini=nul /command open ftpes://ftpuser:password@sftp.mysite.com/ ^

Thanks.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26480
Location: Prague, Czechia
paslechoix wrote:
Thank you. I ran it from command line and it prompts the first line is not a recognized command:
"open ftpes://ftpuser:password@sftp.mysite.com/" ^

Show us a screenshot! Make sure there's no echo off command in the batch file.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26480
Location: Prague, Czechia
Anonymous wrote:
I made some modification to the .bat script but still not working:

"C:\WinSCP\WinSCP.exe /log="C:\SFTP\log\t4log_!Y_!M_!D_!T.log" /loglevel=0 /ini=nul /command open ftpes://ftpuser:password@sftp.mysite.com/ ^

That's a wrong syntax.
And stick with the winscp.com. Do not use winscp.exe in a batch file.
paslechoix
[View user's profile]

Joined: 2016-11-10
Posts: 6
Location: Canada
martin wrote:
Anonymous wrote:
I made some modification to the .bat script but still not working:

"C:\WinSCP\WinSCP.exe /log="C:\SFTP\log\t4log_!Y_!M_!D_!T.log" /loglevel=0 /ini=nul /command open ftpes://ftpuser:password@sftp.mysite.com/ ^

That's a wrong syntax.
And stick with the winscp.com. Do not use winscp.exe in a batch file.


Thank you.

I modified the .exe to .com, it still shows error on the first line and there after.

Please see the screenshot (I'm sorry the first line contains confidential info and is hence excluded from the screenshot but it is like:
C:\WinSCP\WinSCP.com /log="C:\SFTP\log\t4log_!Y_!M_!D_!T.log" /loglevel=0 /ini=nul /command open ftpes://ftpuser:password@sftp.mysite.com/

Thank you
Screenshot - 21_11_2016 , 12_02_07 PM.png (10.11 KB)

Description: (none)

Screenshot - 21_11_2016 , 12_02_07 PM.png

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26480
Location: Prague, Czechia
It's obvious that the batch file is wrong. You have the ^'s wrong. I do not know how else to tell you, to help you to get them right.

Maybe it's time to give up and put everything to a single line:

"C:\WinSCP\WinSCP.com" /log="C:\writable\path\to\log\WinSCP.log" /ini=nul /command "open ftpes://ftpuser:password@sftp.mysite.com/" "synchronize remote \Temp /Distribution/Comp" "exit"

Though the first "The File name, directory name, or volume label syntax is incorrect" error suggests, you might have yet another problem there. I cannot help you with that, if you do not show us the command. You can mask out the sensitive parts. Though, the less information you mask out, the more likely we will be able to help you.
paslechoix
[View user's profile]

Joined: 2016-11-10
Posts: 6
Location: Canada
martin wrote:
It's obvious that the batch file is wrong. You have the ^'s wrong. I do not know how else to tell you, to help you to get them right.

Maybe it's time to give up and put everything to a single line:

"C:\WinSCP\WinSCP.com" /log="C:\writable\path\to\log\WinSCP.log" /ini=nul /command "open ftpes://ftpuser:password@sftp.mysite.com/" "synchronize remote \Temp /Distribution/Comp" "exit"

Though the first "The File name, directory name, or volume label syntax is incorrect" error suggests, you might have yet another problem there. I cannot help you with that, if you do not show us the command. You can mask out the sensitive parts. Though, the less information you mask out, the more likely we will be able to help you.


Thank you, your script is partly working with a different error:

Error listing directory '/Distribution/TheFolder'
Error retrieving file list for '/Distribution/TheFolder\*.*'
System Error. Code: 3.

How can I fix it?

Thanks lots.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26480
Location: Prague, Czechia
Please attach a log file.
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