KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

[Q] result modification

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
menno



Joined: 21 May 2010
Posts: 126

PostPosted: Fri Feb 17, 2017 7:23 am    Post subject: [Q] result modification Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2826

PostPosted: Fri Feb 17, 2017 8:27 am    Post subject: Reply with quote

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%


Last edited by KS-Soft Europe on Fri Feb 17, 2017 11:43 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
menno



Joined: 21 May 2010
Posts: 126

PostPosted: Fri Feb 17, 2017 9:11 am    Post subject: Reply with quote

yess i messed up
Thanks this works great !

menno
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2826

PostPosted: Fri Feb 17, 2017 11:26 am    Post subject: Reply with quote

You are welcome!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index