Forum Discussion
6 Replies
- jackson_1Frequent Contributorhi alex,
can you give me an example with delphi script.
Thanks very much!
Hi Du,
We will create the needed script, publish it in the How To section of our web site and post a link to it here.- VLapidusFrequent ContributorHi,
You can use the example from the link:
http://smartbear.com/support/viewarticle/8963/
In the code, you need to modify the Test function:contents := 'Execution result: ' + ExecAndWaitForEnd('ping', 'ComputerName'));
Then, you will be able to extract the Ip from the contents
function ParseIP(TextOutput);var
MyRegExp: OleVariant;
ResStr: String;
begin
MyRegExp:=HISUtils.RegExpr;
ResStr:='';
MyRegExp.Expression:='(\d{1,3}\.){3}\d{1,3}';if
MyRegExp.Exec(TextOutput) thenResStr :=
MyRegExp.Match[0];result := ResStr;
end;
- jackson_1Frequent Contributorhi;
i am done this scripts. share it there.function ResolveIP(ComputerName): string;
var
objShell,objExec,RegEx;
var
StrOutput: string;
beginobjShell: = Sys.OleObject['WScript.Shell'];
objExec: = objShell.Exec('Ping ' + ComputerName + ' -n 1');
StrOutput: = objExec.StdOut.ReadAll;
RegEx: = HISUtils.RegExpr;
RegEx.Expression: = '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})';Regex.Exec(StrOutput);
if RegEx.MatchPos[0] then
result: = RegEx.Substitute('$&')
else
result: = 'IP Address colud not be resolved.!';
end; - jackson_1Frequent Contributor
there is a change in windows 7 OS.
function ResolveIP(ComputerName): string;var
objShell,objExec,RegEx;
var
StrOutput: string;
beginobjShell: = Sys.OleObject['WScript.Shell'];
objExec: = objShell.Exec('Ping ' + ComputerName + ' -4');
StrOutput: = objExec.StdOut.ReadAll;
RegEx: = HISUtils.RegExpr;
RegEx.Expression: = '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})';Regex.Exec(StrOutput);
if RegEx.MatchPos[0] then
result: = RegEx.Substitute('$&')
else
result: = 'IP Address colud not be resolved.!';
end;