string subtitution

  • Thread starter Thread starter Henry
  • Start date Start date
H

Henry

Hi

How can I replace certain portions of an instring?

I'm trying to resolve SNMP messages by substituting the
OID numbering with the relevant description. Example: I
would like to replace the instring with the resolved
string:
Instring= OID: 1.3.6.1 Value: ABC OID: 1.3.6.5 Value:
Critical OID: 1.3.6.7 Value: 13:05
Resolved string= Server: ABC Status: Critical Time: 13:05

Any ideas how or maybe a tool???? Any input will be
appreciated
 
Henry said:
How can I replace certain portions of an instring?

I'm trying to resolve SNMP messages by substituting the
OID numbering with the relevant description. Example: I
would like to replace the instring with the resolved
string:
Instring= OID: 1.3.6.1 Value: ABC OID: 1.3.6.5 Value:
Critical OID: 1.3.6.7 Value: 13:05
Resolved string= Server: ABC Status: Critical Time: 13:05

Any ideas how or maybe a tool???? Any input will be
appreciated
Hi

@echo off
Set InString=OID: 1.3.6.1 Value: ABC OID: 1.3.6.5 Value: Critical OID: 1.3.6.7 Value: 13:05
for /f "Tokens=4" %%a in ("%InString%") do set OIDServer=%%a
for /f "Tokens=8" %%a in ("%InString%") do set OIDStatus=%%a
for /f "Tokens=12" %%a in ("%InString%") do set OIDTime=%%a
echo Server: %OIDServer% Status: %OIDStatus% Time: %OIDTime%
 
Back
Top