Getting info from a process

BlitzMax Forums/BlitzMax Programming/Getting info from a process

This is because processes are actually run with two pipes: StandardIO (in Pub.FreeProcess, this is myproc.pipe); and StandardError (in Pub.FreeProcess, this is myproc.err). Any output that represents an error is sent to the special (.err) pipe so that it can be identified and processed separately to normal output. Therefore, you will need to catch data from this pipe too.

Try something like (untested):

exec$=(AppDir+"\upx.exe -v target.exe")
Local myproc:TProcess = TProcess.Create (exec$ , 0)
Local bytes:Byte[]
Local result:String=""
If myproc
	While True
		bytes = myproc.pipe.readpipe()
		If bytes
			result:+ string.frombytes(bytes , Len bytes)				
		End If

		bytes = myproc.err.readpipe()	'Add this to catch any output from the StandardError pipe
		If bytes
			result:+ string.frombytes(bytes , Len bytes)		
		End If
		If Not myproc.status() Exit
		Print ":"+result+":"
		Delay 10
	Wend
End If
Print "Final result: "+result
myproc.Close()
You may also want to read this thread where we were explaining a lot of the problems you may encounter with using Pub.FreeProcess, including what I've mentioned above.