Logging the ping result using .wsf on putty

Logging the ping result using the command below. everything works fine, but i cant seem to find a way to log the ping result on a txt file.

<package>
   <job id="vbs">
      <script language="VBScript">
         set WshShell = WScript.CreateObject("WScript.Shell")
         WshShell.Run "putty.exe -ssh username@Server-ip -pw password"
         WScript.Sleep 2000
        WshShell.SendKeys "username" - for previlage
         WScript.Sleep 1000
         WshShell.SendKeys "~"
         WScript.Sleep 2000
      WshShell.SendKeys "password" - for previlage
      WScript.Sleep 1000
      WshShell.SendKeys "~"
      WshShell.SendKeys "ping X.X.X.X count 1000"
      WshShell.SendKeys "~"
      wscript.quit
         
      </script>
   </job>
</package>
Paolo ManzanoAsked:
Who is Participating?
 
dsuyemotoCommented:
Your question seems to have been mislabeled as Powershell.

To answer your question, though, you can change this:
WshShell.SendKeys "ping X.X.X.X count 1000"

To this:
WshShell.SendKeys "ping X.X.X.X count 1000 > ping.txt" to overwrite
or
WshShell.SendKeys "ping X.X.X.X count 1000 >> ping.txt" to append
0
 
dsuyemotoCommented:
Question has been answered
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.