
Running shell command and recording output
Any idea how I can run a shell command and record the output for use later?
I have tried using the WSH shell run command with the command piping out to
a text file, but this does not seem to work
Background
========
I am trying to write a script that lets me input a start IP address and an
end IP address and ping everything between.
The script I have thus far is:
Option Explicit
Dim FSO, WSHShell, IPSubnet, IPStart, IPEnd, f, i, cmdPing, my_RETURN
Set FSO = CreateObject("Scripting.FileSystemObject")
set WSHShell=Wscript.CreateObject("Wscript.Shell")
IPSubnet = InputBox("Enter first three octets of IP range, e.g.
165.244.217")
IPStart = InputBox("Enter First IP Address in range","IP Start")
IPEnd = InputBox("Enter Last IP Address in range","IP End")
set f = FSO.CreateTextFile("c:\ping.txt", TRUE)
f.WriteLine("Results of ping for IP range " & IPSubnet _
& "." & IPStart & " to " & IPSubnet & "." & IPEnd)
f.Close
'Ping through IP Addresses and return results
For i = IPStart to IPEnd
cmdPing = "ping -a -n 1 "& IPSubnet & "." & i & " >> c:\ping.txt"
my_Return = WSHShell.Run(cmdPing ,1, TRUE)
NEXT
Thanks in advance
Mark Salter
LG Electronics Wales