Need help with script -

Advertisement

Natasha
Joined:
Posts:
2
Location:
Sunny San Diego

Need help with script -

Hi Admins,

Newbie here.

Maybe you guys can help.

[code]
@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\ftp2\WinSCP.log" /ini=nul ^
/command ^
"open ftp://mysite:Pa$$w0rd@IP.ADDR/" ^
"synchronize remote -mirror \\<My local share>\path\xyz\abc /temp"" ^
"exit"

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

exit /b %WINSCP_RESULT%
[/code]
Guys I am simply trying to sync my \\localshare path\ with the remote dirctory on "mysite"
And keep on getting:

[code]
. 2016-09-16 19:04:00.386 Error listing directory '/temp ^'. ("Could not retrieve directory listing","Failed to change directory.")
< 2016-09-16 19:04:00.386 Script: Error listing directory '/temp ^'.
< 2016-09-16 19:04:00.390 Script: Could not retrieve directory listing

< 2016-09-16 19:04:00.390 Failed to change directory.
. 2016-09-16 19:04:00.405 Script: Failed
. 2016-09-16 19:04:00.405 Script: Exit code: 1
. 2016-09-16 19:04:00.407 Disconnected from server
[/code]

I have made the temp directory on the remote server so I know its there, why can't my script find it, even though it connects just fine? Please help, ..

Basically, I want to:
a) copy all files from my \\share to the remote directory \\temp
b) schedule a batch job to keep the files insync
Thats all.

Let me know if you guys can help me with the script, thanks.[/code]

Reply with quote

Advertisement

JeroenE
Joined:
Posts:
9
Location:
The Netherlands

Are you really using the ^ in your script? I think that is the problem. You should remove the ^ and then add the next line on the same line. Also the quotes are not correct everywhere.

So instead of
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\ftp2\WinSCP.log" /ini=nul ^
/command ^
"open ftp://mysite:Pa$$w0rd@IP.ADDR/" ^
"synchronize remote -mirror \\<My local share>\path\xyz\abc /temp"" ^
"exit"
I think it should be
"C:\Program Files (x86)\WinSCP\WinSCP.com" /log="C:\ftp2\WinSCP.log" /ini=nul /command "open ftp://mysite:Pa$$w0rd@IP.ADDR/" synchronize remote -mirror "\\<My local share>\path\xyz\abc /temp" "exit"

Reply with quote

Natasha
Joined:
Posts:
2
Location:
Sunny San Diego

Thnx,

Here is the result now, please advise,

C:\ftp2>"C:\Program Files (x86)\WinSCP\WinSCP.com" /log="C:\ftp2\WinSCP.log" /ini=nul /command "open ftp://mysite:Pa$$w0rd@IP.ADDR/ synchronize remote -mirror "synchronize remote -mirror \\<My local share>\path\xyz\abc /temp" "exit"
Scripting does not use standalone parameters. The parameters you have specified on command-line will not be used. Your command-line syntax is probably wrong.
Opening session using command-line parameter in scripting is deprecated. Use 'open' command instead.
Searching for host...
Host "\\<mysite>\share\share\share" does not exist.
Connecting to IP.ADDR/
Connected
Starting the session...
Session started.
Active session: [1] mysite@IP.ADDR/
Missing parameter for command 'synchronize'.

Log:
2016-09-17 14:18:43.458 --------------------------------------------------------------------------
. 2016-09-17 14:18:43.458 Session name: mysite@IP.ADDR/ (Ad-Hoc site)
. 2016-09-17 14:18:43.458 Host name: IP.ADDR/ (Port: 21)
. 2016-09-17 14:18:43.458 User name: mysite (Password: Yes, Key file: No)
. 2016-09-17 14:18:43.458 Transfer Protocol: FTP
. 2016-09-17 14:18:43.458 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec
. 2016-09-17 14:18:43.458 Disable Nagle: No
. 2016-09-17 14:18:43.458 Proxy: None
. 2016-09-17 14:18:43.458 Send buffer: 262144
. 2016-09-17 14:18:43.458 UTF: Auto
. 2016-09-17 14:18:43.458 FTPS: None [Client certificate: No]
. 2016-09-17 14:18:43.458 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto
. 2016-09-17 14:18:43.458 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2016-09-17 14:18:43.458 Cache directory changes: Yes, Permanent: Yes
. 2016-09-17 14:18:43.458 Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
. 2016-09-17 14:18:43.458 Timezone offset: 0h 0m
. 2016-09-17 14:18:43.458 --------------------------------------------------------------------------
. 2016-09-17 14:18:43.463 Connecting to IP.ADDR/ ...
. 2016-09-17 14:18:43.685 Connected with IP.ADDR/. Waiting for welcome message...
< 2016-09-17 14:18:43.697 220-
< 2016-09-17 14:18:43.697 220-|-----------------------------------------------------------------|
< 2016-09-17 14:18:43.708 220-| This system is for the use of authorized users only.            |
< 2016-09-17 14:18:43.708 220-| Individuals using this computer system without authority, or in |
< 2016-09-17 14:18:43.708 220-| excess of their authority, are subject to having all of their   |
< 2016-09-17 14:18:43.708 220-| activities on this system monitored and recorded by system      |
< 2016-09-17 14:18:43.708 220-| personnel.                                                      |
< 2016-09-17 14:18:43.708 220-|                                                                 |
< 2016-09-17 14:18:43.708 220-| In the course of monitoring individuals improperly using this   |
< 2016-09-17 14:18:43.708 220-| system, or in the course of system maintenance, the activities  |
< 2016-09-17 14:18:43.708 220-| of authorized users may also be monitored.                      |
< 2016-09-17 14:18:43.709 220-|                                                                 |
< 2016-09-17 14:18:43.709 220-| Anyone using this system expressly consents to such monitoring  |
< 2016-09-17 14:18:43.709 220-| and is advised that if such monitoring reveals possible         |
< 2016-09-17 14:18:43.709 220-| evidence of criminal activity, system personnel may provide the |
< 2016-09-17 14:18:43.709 220-| evidence of such monitoring to law enforcement officials.       |
< 2016-09-17 14:18:43.709 220-|-----------------------------------------------------------------|
< 2016-09-17 14:18:43.709 220-
< 2016-09-17 14:18:43.709 220 
> 2016-09-17 14:18:43.709 USER mysite
< 2016-09-17 14:18:43.720 331 Please specify the password.
> 2016-09-17 14:18:43.720 PASS *********
< 2016-09-17 14:18:43.742 230 Login successful.
> 2016-09-17 14:18:43.742 SYST
< 2016-09-17 14:18:43.752 215 UNIX Type: L8
> 2016-09-17 14:18:43.752 FEAT
< 2016-09-17 14:18:43.763 211-Features:
< 2016-09-17 14:18:43.763  EPRT
< 2016-09-17 14:18:43.763  EPSV
< 2016-09-17 14:18:43.774  MDTM
< 2016-09-17 14:18:43.774  PASV
< 2016-09-17 14:18:43.774  REST STREAM
< 2016-09-17 14:18:43.774  SIZE
< 2016-09-17 14:18:43.774  TVFS
< 2016-09-17 14:18:43.774  UTF8
< 2016-09-17 14:18:43.774 211 End
> 2016-09-17 14:18:43.774 OPTS UTF8 ON
< 2016-09-17 14:18:43.784 200 Always in UTF8 mode.
. 2016-09-17 14:18:43.784 Connected
. 2016-09-17 14:18:43.784 --------------------------------------------------------------------------
. 2016-09-17 14:18:43.784 Using FTP protocol.
. 2016-09-17 14:18:43.784 Doing startup conversation with host.
> 2016-09-17 14:18:43.784 PWD
< 2016-09-17 14:18:43.795 257 "/"
. 2016-09-17 14:18:43.795 Getting current directory name.
. 2016-09-17 14:18:43.795 Startup conversation with host finished.
< 2016-09-17 14:18:43.795 Script: Active session: [1] mysite@IP.ADDR/
> 2016-09-17 14:18:43.795 Script: synchronize
< 2016-09-17 14:18:43.796 Script: Missing parameter for command 'synchronize'.
. 2016-09-17 14:18:43.796 Script: Failed
. 2016-09-17 14:18:43.796 Script: Exit code: 1
. 2016-09-17 14:18:43.800 Disconnected from server
I think its some feature of synchronize command that its not taking correctly?








JeroenE wrote:

Are you really using the ^ in your script? I think that is the problem. You should remove the ^ and then add the next line on the same line. Also the quotes are not correct everywhere.

So instead of
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\ftp2\WinSCP.log" /ini=nul ^
/command ^
"open ftp://mysite:Pa$$w0rd@IP.ADDR/" ^
"synchronize remote -mirror \\<My local share>\path\xyz\abc /temp"" ^
"exit"
I think it should be
"C:\Program Files (x86)\WinSCP\WinSCP.com" /log="C:\ftp2\WinSCP.log" /ini=nul /command "open ftp://mysite:Pa$$w0rd@IP.ADDR/" synchronize remote -mirror "\\<My local share>\path\xyz\abc /temp" "exit"
:roll: :roll: :roll: :roll: :roll:

Reply with quote

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

Re: Need help with script -

It's not true that you cannot use the ^ in Windows batch file. Of course, you can. Your problem is those two quotes after the /temp.

This should work:

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\ftp2\WinSCP.log" /ini=nul ^
  /command ^
  "open ftp://mysite:Pa$$w0rd@IP.ADDR/" ^
  "synchronize remote -mirror \\<My local share>\path\xyz\abc /temp" ^
  "exit"

Reply with quote

Advertisement

You can post new topics in this forum