executing external commands...

BlitzMax Forums/BlitzMax Programming/executing external commands...

orgos(Posted 2009) [#1]
Hi.

I look some info for execute externals commands and i found one function called system_ and TProcess class, but my problem is that i need to get the result values of the external execution

How i can get the result values?


Brucey(Posted 2009) [#2]
system_ returns the exit code, doesn't it?


orgos(Posted 2009) [#3]
Nope, i need the result of executed command for example:

if i execute "dir.exe" on windows i need the result of that (is an example)


kfprimm(Posted 2009) [#4]
I believe you can stream output from the TProcess's "pipe" and "error" members. Actually, it may be "_pipe" and "_error." Sorry, i'm not in front of a computer right now. Check the PUB.FreeProcess module.


em22(Posted 2009) [#5]
I'm surprised not to find an easy solution to this.


em22(Posted 2009) [#6]
Dont know if this will help :

Local str:String = "c:\windows\system32\calc.exe"

Local process:TProcess = CreateProcess(str, HIDECONSOLE)

While Not KeyHit( KEY_ESCAPE )


If ProcessStatus(process:TProcess) = True
	Print "still running"
Else
	Print "seems gone"
EndIf

Delay(10)

Wend



em22(Posted 2009) [#7]
Been playing a bit more and now I can read the the output of cmd.exe /?:


Local str:String = "cmd.exe /?"

Local process:TProcess = CreateProcess(str, SHOWCONSOLE)

While Not KeyHit( KEY_ESCAPE )

If Process.err.ReadAvail() Or Process.pipe.ReadAvail() Then

linepipe:String = process.pipe.ReadLine().Trim()
lineerro:String = process.err.ReadLine().Trim()

If linepipe <> "" Then
Print linepipe

EndIf
If lineerro <> "" Then
Print lineerro

EndIf
EndIf


Wend



orgos(Posted 2009) [#8]
Thanks em22, thats work.