Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

The either is the correct option, as documented.

But the both is also accepted for a backwards compatibility reason, with the same meaning as the either.
jrp78

Martin,

I was just reviewing my code and I'm wondering if I have the criteria switch is incorrect.

Documentation states: -criteria=<criteria> Comparison criteria. Possible values are time, size, either and none. Ignored for both mode.

"synchronize local d:\inetpub\web\ /web/ -criteria=both -filemask=""| alert.xml; emergency.xml; .htaccess; notice.xml; sitemap.xml; web.config; wincache.php; fileshare/; xml-sitemap-generator/"""

I have both in there but am I reading the documentation incorrectly? I want it to compare both time and file size. Should I be using -criteria=either instead?
jrp78

martin wrote:

Thanks. I was under the impression "option synchdelete on" was the accomplishing the sync delete. If -delete in the sync string does it, do I even need "option synchdelete on" in my script?

Ok, I've missed the synchdelete. It does the same as the -delete, but it's deprecated.
Use the -delete switch instead.


Cool, thanks Martin.
martin

Thanks. I was under the impression "option synchdelete on" was the accomplishing the sync delete. If -delete in the sync string does it, do I even need "option synchdelete on" in my script?

Ok, I've missed the synchdelete. It does the same as the -delete, but it's deprecated.
Use the -delete switch instead.
Guest

martin wrote:

Would be easier, if you explicitly name the options, we should look for.

You are definitely missing the -delete switch for the Synchronize options > Delete files.


Thanks. I was under the impression "option synchdelete on" was the accomplishing the sync delete. If -delete in the sync string does it, do I even need "option synchdelete on" in my script?
martin

Would be easier, if you explicitly name the options, we should look for.

You are definitely missing the -delete switch for the Synchronize options > Delete files.
Guest

Well, I got it working but I'm still concerned if I have the settings in the command line matching the GUI exactly? See previous post for pic. Thanks again.

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\scripts\WinSCP-5.9.1-Portable\t4log_!Y_!M_!D_!T.log" /loglevel=0 /ini=nul ^
/command ^
"open sftp://username@serverip/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx"" -privatekey=""C:\scripts\Puttygen\privkey.ppk""" ^
"option batch abort" ^
"option transfer binary" ^
"option synchdelete on" ^
"synchronize local d:\inetpub\web\ /web/ -criteria=both -filemask=""| alert.xml; emergency.xml; .htaccess; notice.xml; sitemap.xml; web.config; wincache.php; fileshare/; xml-sitemap-generator/""" ^
"close" ^
"quit" ^
"exit"

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

exit /b %WINSCP_RESULT%
jrp78

Scripting help!!

I'm struggling to understand scripting. I can do exactly what I want in the GUI but can't figure out how to script it all. I'm connecting to an SFTP server with a private key and synchronizing files remotely to a local copy. It works awesome in the GUI but I need to setup a script to run every hour. I have attached a screenshot of all the settings I'd like to have in the script. Could someone be so kind as to help me out or point me to a good example of everything I'm trying to do.

Needs:
1. Syntax for opening connection to SFTP server with PPK
2. Syntax for all the options as shown in the attached screenshot.

Here's what I started trying to piece together but I no clue if it's right.

WinSCP.com /command ^
"option batch abort" ^
"option transfer binary" ^
"option synchdelete on" ^
"option exclude "D:\inetpub\web\alert.xml;D:\inetpub\web\emergency.xml;D:\inetpub\web\.htaccess;D:\inetpub\web\notice.xml;D:\inetpub\web\sitemap.xml;D:\inetpub\web\web.config;D:\inetpub\web\wincache.php;D:\inetpub\web\fileshare\;D:\inetpub\web\xml-sitemap-generator\" ^
"open sftp://username@xxx.xxx.xxx.xxx/ /privatekey=C:\scripts\Puttygen\privkey.ppk" ^
"synchronize local d:\inetpub\web\ /web/" -preview ^
"close" ^
"quit" ^
/log="C:\scripts\WinSCP-5.9.1-Portable\t4log!Y_!M_!D_!T.log" /loglevel=0

[/img]