Hi team
maybe this is a stupid question ... sorry for that
i have a Shell script running that execute the command :
cmd /c ipconfig |findstr IPv4
I "tune up the reply value" with this string :
[replace(replace('%SuggestedReply%','"',''),'IPv4 Address. . . . . . . . . . . : ','')]
the script contains this text :
statusUnknown = "ScriptRes:Unknown:"
statusOk = "ScriptRes:Ok:"
statusBad = "ScriptRes:Bad:"
var res = "Ok";
WScript.StdOut.Write(statusOk+res);
But when i do a "let's try"... here comes the stupid question .... It allways replys with Script started, invalid result received:
see here:
[14:18:21] Agent: computer is going to execute "Get ip address windows" script ...
[14:18:21] Script started, invalid result received:
----------
IPv4 Address. . . . . . . . . . . : 192.168.1.213
Hostmonitor reply field : Error: Invalid result (192.168.1.213)
What need i todo to remove this Error: Invalid result and only get the ip address
The script allways can end up with an OK
We just want to check the ip address .
Many thaks in advance
menno
[Q] result modification
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Any script, used with Shell Script test method should return reply in the following format:
ScriptRes:<status>:<reply text>
E.g.:
ScriptRes:Ok:some reply test
ScriptRes:Bad:other reply test
You also mixed Windows batch with VB script
"tune up the reply value" option performs modifications later.
This can be done in different ways:
1.
start cmd:
cmd /c %Script% %Params%
script:
echo off
for /f "usebackq tokens=2 delims=:" %%i in (`ipconfig ^| findstr /c:IPv4`) do echo ScriptRes:Ok:%%i
2.
start cmd:
cmd /c %Script% %Params%
script:
echo off
for /f "skip=1 delims={}, " %%A in ('wmic nicconfig get ipaddress') do for /f "tokens=1" %%B in ("%%~A") do set "IP=%%~B"
echo ScriptRes:Ok:%IP%
ScriptRes:<status>:<reply text>
E.g.:
ScriptRes:Ok:some reply test
ScriptRes:Bad:other reply test
You also mixed Windows batch with VB script
"tune up the reply value" option performs modifications later.
This can be done in different ways:
1.
start cmd:
cmd /c %Script% %Params%
script:
echo off
for /f "usebackq tokens=2 delims=:" %%i in (`ipconfig ^| findstr /c:IPv4`) do echo ScriptRes:Ok:%%i
2.
start cmd:
cmd /c %Script% %Params%
script:
echo off
for /f "skip=1 delims={}, " %%A in ('wmic nicconfig get ipaddress') do for /f "tokens=1" %%B in ("%%~A") do set "IP=%%~B"
echo ScriptRes:Ok:%IP%
Last edited by KS-Soft Europe on Fri Feb 17, 2017 11:43 am, edited 1 time in total.
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact: