Replace an IP in the "hosts" file with the IP from a ping result
Posted: 18 Sep 2021, 03:44
Hi there!
I would like to write a script that when triggered would do the following:
1. Execute the following Command Prompt line: "ping aaa".
2. Extract the IP address of the computer named "aaa" and store it in a variable ("new_ip").
3. Open the "hosts" file and replace the "192.168.43.2 osc_server" line with this one: "%new_ip% osc_server".
I would like to know how to do the first two steps.
Thank you!
I would like to write a script that when triggered would do the following:
1. Execute the following Command Prompt line: "ping aaa".
2. Extract the IP address of the computer named "aaa" and store it in a variable ("new_ip").
3. Open the "hosts" file and replace the "192.168.43.2 osc_server" line with this one: "%new_ip% osc_server".
I would like to know how to do the first two steps.
Thank you!