Micro Focus QTP (UFT) Forums
Vb script for a task - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Vb script for a task (/Thread-Vb-script-for-a-task)



Vb script for a task - siri - 06-16-2010

Hi All,



need help on a vb script

task:

1. we have an excel of 2 columns onw with host name and 2 with Ip Adress
2.Write a code ns lokkup host name in CMd prompt and get the Ip adress
3. COmpare the 2 ip adresses
4.iff the IP macthces then true msg box or esle false


RE: Vb script for a task - Saket - 06-16-2010

You can use wscipt.shell to execute the command and get the output using stdout.readall method.
here is some guidelines you can use -
1. get the host name and ip address from excel
2. Execute the ns lookup command with the returned host name
3. Get the output with stdout
4. Parse the ip address and compare


RE: Vb script for a task - siri - 06-22-2010

thanks saket .

can u let me know any sample code
I tried recording through QTP but the C command prompt are not captured by QTP


RE: Vb script for a task - Saket - 06-23-2010

Code:
Set oWshShell = CreateObject("wscript.Shell")
sCmd = "nslookup .." 'put your command here

Set oExec = oWshShell.Exec(sCmd)
sStdout = oExec.StdOut.ReadAll
sStdErr = oExec.StdErr.ReadAll

MsgBox "stdout: " & sStdout &  " stderr: " & sStderr
let me know if this helps