[转贴]获得IP的函数

上一篇 / 下一篇  2008-08-19 18:41:39 / 个人分类:SilkTest

[+] public String GetIpAddress(String sMachineName)
[ ] //To get IP Address for the particular machine in Network
[ ] List of String lsOutput
[ ] String sCommand
[ ] String sTemp, sItem
[ ] String sResult = NULL
[ ] Boolean bResult = FALSE
[ ] Integer iPos1, iPos2
[ ]
[ ] sCommand = "ping -a {sMachineName}"
[ ] Sys_Execute (sCommand,lsOutput)
[ ]
[ ] //ListPrint (lsOutput)
[-] for each sItem in lsOutput
[-] if (MatchStr("*pinging*", sItem))
[ ] bResult = TRUE
[ ] break
[ ]
[-] if (bResult)
[ ] iPos1 = StrPos ("[", sItem)
[ ] iPos2 = StrPos ("]", sItem)
[-] if ((iPos1 > 0) && (iPos2 > 0))
[ ] sResult = SubStr(sItem,iPos1+1, iPos2-iPos1-1)
[ ] Print ("Found IP Address: {sResult}")
[ ] return sResult

TAG: SilkTest

 

评分:0

我来说两句

Open Toolbar