executing external commands...
BlitzMax Forums/BlitzMax Programming/executing external commands...
| ||
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? |
| ||
system_ returns the exit code, doesn't it? |
| ||
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) |
| ||
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. |
| ||
I'm surprised not to find an easy solution to this. |
| ||
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 |
| ||
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 |
| ||
Thanks em22, thats work. |