How can i...

Advertisement

MiamiHoris
Guest

How can i...

Good afternoon...

I have been trying to make this work for over a week now with no luck.
I am new to this. I am running winscp 5.9

I wrote a few reports that need to upload to an sftp site on a daily basis.

first off can 5.9 have a way to automate this upload?

I try using the code generator, however i am unfamiliar with how to enter the code correctly, and even more so how to execute it afterwards.

I can add a batch file to the task scheduler. but what is the correct way to get this to synchronize?

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
/command ^
"open sftp:blah blah/ -hostkey=""ssh-rsa blah-blah""blah" ^
"Your command 1" ^
"synchronize remote C:\Blah-blah /to_blah
"Your command 2" ^
"exit"

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

exit /b %WINSCP_RESULT%

Reply with quote

Advertisement

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

Re: How can i...

Your code is generally correct.

But obviously you need to
- Remove the placeholder lines "Your command 1" ^ and "Your command 2" ^.
- Use a real path for the log, not the placeholder path C:\writable\path\to\log\WinSCP.log

Reply with quote

MiamiHoris
Guest

thanks martin

"synchronize remote C:\Files /to_bh" ^

the above string is giving me this...


Searching for host...
Connecting to host...
Authenticating...
Using username "******".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] *********.net
Too many parameters for command 'synchronize'.
Error
Press any key to continue . . .

Reply with quote

MiamiHoris
Guest

ok i got this far

when i use:

"synchronize remote"

how should the upload string look like...

i have now:

"synchronize remote" "C:\B*** H***\Files\ /to_bh" ^

which is grabbing the info but putting it in wrong directory

Searching for host...
Connecting to host...
Authenticating...
Using username "*********".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] ****************
Comparing...
Local 'C:\B** H***\Files' => Remote '/Files'
Synchronizing...
Local 'C:\B** H**' => Remote '/'
BH_SFTP_Daily_Upload.bat | 426 B | 0.0 KB/s | binary | 100%
Local 'C:\Baker Hill\Files' => Remote '/Files'
C:\...\B********.csv | 312 KB | 89.5 KB/s | binary | 100%
C:\...\B********.FDF | 1 KB | 81.4 KB/s | binary | 100%
C:\...\Files\B*******.csv | 4844 KB | 368.0 KB/s | binary | 100%
C:\...\Files\B*******.FDF | 2 KB | 359.7 KB/s | binary | 100%
C:\...\Files\B*******.csv | 515 KB | 316.3 KB/s | binary | 100%
C:\...\Files\B*******.FDF | 1 KB | 360.0 KB/s | binary | 100%
C:\...\B********.csv | 764 KB | 320.1 KB/s | binary | 100%
C:\...\B********.FDF | 1 KB | 290.2 KB/s | binary | 100%
C:\...\Files\B******.csv | 571 KB | 238.3 KB/s | binary | 100%
C:\...\Files\B******.FDF | 2 KB | 208.3 KB/s | binary | 100%
Unknown command 'C:\Baker'.
Error
Press any key to continue . . .

Reply with quote

MiamiHoris
Guest

Last Issue

Ok after much trial and error... i figured out my batch script needs to be inside the folder i wish to sync...

however it still not placing it in the correct target folder, i need it to go to /to_bh

"synchronize remote"
"C:\to_bh\ /to_bh" ^

however it places the files on the outside of this directory no inside of the /to_bh.

what am i missing here?

Reply with quote

Advertisement

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

Re: Last Issue

MiamiHoris wrote:

Ok after much trial and error... i figured out my batch script needs to be inside the folder i wish to sync...
No it does not have to.

I do not get the problem you describe with a script like:

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
  /command ^
  "open sftp://username:password@example.com/ -hostkey=""ssh-rsa xx:xx""" ^
  "synchronize remote C:\Blah-blah /to_blah" ^
  "exit"

It works correctly (as expected).

Show us your current exact batch file.

Reply with quote

Advertisement

You can post new topics in this forum