Jump to content

DOS output to variable


Recommended Posts

I did some searching and it appears the way to do this is send the output to a temp text file and then read it back. Is there a simpler way?

RunWait( "cmd /c c:\windows\system32\snmputil.exe get 176.88.15.30 Public .1.3.6.1.2.1.2.2.1.10.4" & ">" & "temp.txt" )
$output= FileRead( "temp.txt", FileGetSize("temp.txt") )
FileDelete( "temp.txt" )

This works, just looking for input on the best way to run a DOS app and dump the output to a variable. Is the step of writing to a file needed?

Edited by SystemWontAccept
Link to comment
Share on other sites

Hi.

Script writed by MAT.

It works excelent.

Local $sCommand = "c:\windows\system32\snmputil.exe get 176.88.15.30 Public .1.3.6.1.2.1.2.2.1.10.4" 

MsgBox (0, "", _RunCmd ($sCommand)) 

Func _RunCmd ($sCommand) 
 If StringLeft ($sCommand, 1) = " " Then $sCommand = " " & $sCommand 

 Local $nPid = Run (@Comspec & " /c" & $sCommand, "", @SW_Hide, 8), $sRet = "" 
 If @Error then Return "ERROR:" & @ERROR 
 ProcessWait ($nPid) 
 While 1 
 $sRet &= StdoutRead($nPID) 
 If @error Or (Not ProcessExists ($nPid)) Then ExitLoop 
 WEnd 
 Return $sRet 
EndFunc ; ==> _RunCmd
[size="5"] [/size]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...