#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    Capture output of running CMD


    Dear Team,

    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
    dim a,s

    s=createobject("scripting.filesystemobject").opentextfile(filespec,1,true).readall
    a=split(s,vbcrlf)
    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)
    WScript.Sleep 1000
    oShell.SendKeys"isadmin"
    oShell.SendKeys("{Enter}")
    WScript.Sleep 1000
    oShell.SendKeys"mtnl@123"
    oShell.SendKeys("{Enter}")
    WScript.Sleep 1000
    oShell.SendKeys"show equipment slot"
    oShell.SendKeys("{Enter}")
    WScript.Sleep 5000

    oShell.SendKeys"logout"
    oShell.SendKeys("{Enter}")
    WScript.Sleep 1000


    Loop
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,443
    Rep Power
    4539
    Maybe something in this search will help

    https://www.google.com/search?aq=f&g...capture+stdout
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    23
    Rep Power
    0

    cmd output


    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

IMN logo majestic logo threadwatch logo seochat tools logo