Interview Questions

How can we get the IP address of a PC?

SilkTest Questions and Anwsers


(Continued from previous question...)

39. How can we get the IP address of a PC?

You can use the following
main
[ ] INTEGER iReturn
[ ] STRING sCmdLine = "ipconfig"
[ ] LIST OF STRING lsOutput
[ ] iReturn = SYS_Execute (sCmdLine , lsOutput)
[ ] listprint(lsOutput)

output is
[ ] Windows IP Configuration
[ ] Ethernet adapter Local Area Connection:
[ ] Connection-specific DNS Suffix . : abcd.xyz.net
[ ] IP Address. . . . . . . . . . . . : 1x.2xx.2xx.79
[ ] Subnet Mask . . . . . . . . . . . : 255.255.0.
[ ]Default Gateway . . . . . . . . . : 10.206.1.1

You need to do some trickery to parse and get the IP string..

(Continued on next question...)

Other Interview Questions