VBScript - Capturing output from stdout -


i know has been answered 1 in question, not understand how done.

i trying output of command line program (aria2 downloader) hta script can parsed , download percentage, file size etc can obtained , updated div dynamically.

here code have adjusted , have been trying use locks interface until command line has finished , displays output, instead of displaying , when comes through.

const wshrunning = 0 const wshfinished = 1 const wshfailed = 2 strcommand = "ping.exe 127.0.0.1"  set wshshell = createobject("wscript.shell") set wshshellexec = wshshell.exec(strcommand)  while wshshellexec.status = wshrunning     window.settimeout "", 100 loop  select case wshshellexec.status     case wshfinished         stroutput = wshshellexec.stdout.readall()     case wshfailed         stroutput = wshshellexec.stderr.readall() end select  set objitem = document.getelementbyid("status")     objitem.innerhtml = "" & stroutput & "" 

how modify doesn't lock user interface , grabs output , displays in "status" div comes through?

the problem code not end, returning control browser. don't leave loop until program ends , perceived status interface hangs until subprocess ends.

you need set callback browser periodically call code update status , leave.

<html> <head>     <title>pingtest</title>     <hta:application         applicationname="pingtest"         id="pingtest"         version="1.0"     /> </head>  <script language="vbscript">     const wshrunning = 0     const wshfinished = 1     const wshfailed = 2      dim wshshellexec, interval      sub window_onload         launchprocess     end sub      sub launchprocess         set wshshellexec = createobject("wscript.shell").exec("ping -n 10 127.0.0.1")         interval = window.setinterval(getref("updatestatus"),500)     end sub          sub updatestatus     dim status          set status = document.getelementbyid("status")         select case wshshellexec.status             case wshrunning                 status.innerhtml = status.innerhtml & "<br>" & wshshellexec.stdout.readline()             case wshfinished, wshfailed                 status.innerhtml = status.innerhtml & "<br>" & replace(wshshellexec.stdout.readall(),vbcrlf,"<br>")                 window.clearinterval(interval)                 interval = empty         end select     end sub </script>  <body>     <div id="status"></div> </body> </html> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -