Topic "DR IP Address in Batch Script"

Author Message
JaneDoe3

Guest


Hello -

Looking to see if anyone has added a DR or second rollover/failover IP Address to their WinSCP Batch script?

The Primary Data Center rotates once or twice a year and looking to automate this, so when the script fails to connect to the first IP Address in the script, it rolls to the next IP Address and tries that.
Attempts to try this so far have failed to produce the results I was hoping for.
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
So show us what did you try.

What you can do is to:
- Create a parameterized script with a hostname as the parameter
- Run the script with primary address as the parameter
- If that fails, fall back to the second address.

You can start from these examples:
https://winscp.net/eng/docs/script_upload_multiple_servers
https://winscp.net/eng/docs/guide_automation#results
https://winscp.net/eng/docs/script_retry
JaneDoe3

Guest


@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Temp\Log_%Date:~4,2%%date:~7,2%%date:~10,4%.log" /ini=nul ^
/command ^
"open sftp://username:password@10.99.36.292 -hostkey=""ssh-rsa 2048 """ ^
"open sftp://username:password@10.99.36.183 -hostkey=""ssh-rsa 2048 """ ^

Then it goes into the search for the SFTP folders for download of most recent data.

The error I get: Network Error: Connection to "10.99.36.292" refused.
This is the offline IP Address...the second one is the active one currently.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
JaneDoe3 wrote:
@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Temp\Log_%Date:~4,2%%date:~7,2%%date:~10,4%.log" /ini=nul ^
/command ^
"open sftp://username:password@10.99.36.292 -hostkey=""ssh-rsa 2048 """ ^
"open sftp://username:password@10.99.36.183 -hostkey=""ssh-rsa 2048 """ ^

Then it goes into the search for the SFTP folders for download of most recent data.

The error I get: Network Error: Connection to "10.99.36.292" refused.
This is the offline IP Address...the second one is the active one currently.

This can work too, but you need to set option batch continue before the first open command to avoid the script exiting if the open fails. After the first open, you should reset back to option batch abort.
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