December 6th, 2011, 11:57 PM
Capture output of running CMD
I have a script which automatically telent the multiple switches and displaying switch cards status in CMD,now i want to capture the output which it displays in CMD and save it to some txt files but I am unable to capture those information please help me.
Script is given below.
filespec="C:\node.txt" 'data file with IP addresses
set oShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.OpenTextFile("output.txt", 2, True)
for i=0 to ubound(a)
if trim(a(i))<>"" then
'Launch telnet session from the command line
oShell.Run "telnet " & a(i)
oShell.SendKeys"show equipment slot"
December 7th, 2011, 02:14 PM
Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
December 7th, 2011, 02:57 PM
if you are using cmd then you are using dos
the command in dos to capture the output is the assignment command ">>"
used like this
dir >> a_file.txt
the output of dir is assigned to the file a_file.txt
bill stewart - formerly Incidentals - and hopefully again - real soon...
here to listen