DR IP Address in Batch Script

Advertisement

JaneDoe3
Guest

DR IP Address in Batch Script

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,253
Location:
Prague, Czechia

Re: DR IP Address in Batch Script

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

Reply with quote

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.

Reply with quote

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

Reply with quote

Advertisement

You can post new topics in this forum