Asked by duncanb7
at 2024-03-10 09:05:48
Point:500 Replies:5 POST_ID:828893USER_ID:11059
Topic:
Windows 7;Windows Batch Scripting;Shell Scripting
Dear Expert,
I've one file called "junk.txt" in which I would like to replace Hostname and PortNumber
string with new value using window batch shell script , but I am spending more a few
hour in google, and still can not solve why I can not echo str variabie which
is always empty from following script code, Could you help on this, how to find
a string in string and replace with the new value. And the string addtion is "+" psosible ?
set newip="203.1.123.342"
set newport="00001779"
for /F "tokens=*" %%i in (junk.txt) do set str=%%i & echo %str% & if (%str:~1,9)=="HostName") str='"HostName"="'+'"+newip+'""
Please advise
Duncan
junk.txt file
=============
I've one file called "junk.txt" in which I would like to replace Hostname and PortNumber
string with new value using window batch shell script , but I am spending more a few
hour in google, and still can not solve why I can not echo str variabie which
is always empty from following script code, Could you help on this, how to find
a string in string and replace with the new value. And the string addtion is "+" psosible ?
set newip="203.1.123.342"
set newport="00001779"
for /F "tokens=*" %%i in (junk.txt) do set str=%%i & echo %str% & if (%str:~1,9)=="HostName") str='"HostName"="'+'"+newip+'""
Please advise
Duncan
junk.txt file
=============