Terry Rogers
asked on
Extract Proxy Server from Proxy PAC file in DOS BATCH File
I have a Proxy PAC file that occasionally has the final proxy in the file changed.
I am creating a simple batch script that needs to extract the current value from this file.
The current code reads each line and prints (print is just for testing at present):-
A sample output of this command:-
I need to identify if the current line has the :8080.
I'm not familiar with BATCH scripting (Or scripting in general tbh!)
How best can this be achieved?
I am creating a simple batch script that needs to extract the current value from this file.
The current code reads each line and prints (print is just for testing at present):-
for /f "eol=; tokens=1 delims=," %%i in (\\qahweb02\c$\inetpub\wwwroot\ProxyPac\proxy.pac) do (
echo i: %%i
set name=%%i
echo name: %name%)
A sample output of this command:-
i: else if (isInNet(host
name:
i: return "DIRECT";
name:
i: else if (isInNet(host
name:
i: return "DIRECT";
name:
i: //All other scenarios go to proxy.
name:
i: else
name:
i: return "PROXY myproxyserver.mydomain.com:8080";
name:
i:
name:
i: }
name:
I need to identify if the current line has the
return "PROXY
string, and if it does set a variable to the remainder of that line without the final 2 digits, so I would effectively get a variable filled with myproxyserver.mydomain.comI'm not familiar with BATCH scripting (Or scripting in general tbh!)
How best can this be achieved?
Does it need to be a DOS batch file or can it be powershell?
ASKER
Ideally BATCH as a partial script has already been created, so just need something to drop in.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked perfectly.
Thank you. :)
Thank you. :)