My script of auto sync is not working

Advertisement

paslechoix
Joined:
Posts:
6
Location:
Canada

My script of auto sync is not working

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:
@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.

Reply with quote

Advertisement

paslechoix
Joined:
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.

Reply with quote

martin
Site Admin
martin avatar

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.

Reply with quote

paslechoix
Joined:
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

Reply with quote

Advertisement

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.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
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.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
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.

Reply with quote

paslechoix
Joined:
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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
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.

Reply with quote

paslechoix
Joined:
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.

Reply with quote

Advertisement

You can post new topics in this forum