How do you get pub.freeprocess to read i/o ??

BlitzMax Forums/BlitzMax Programming/How do you get pub.freeprocess to read i/o ??

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm running Vista and it seems to work fine. I think it might be that the IpConfig terminates immediately after it has output the data, and Pub.FreeProcess won't read anymore data from the stream if the process isn't "alive".

The reason for me saying this is that although when I run it, it output information, it is cutting off more lines that you would normally get from the console. Maybe because you have super fast computers, it's cutting it off before it even get's going... Whereas I have loads of virtual adapters on my Vista box that take longer to output.

Does this give you any better results? Can you post your output?

SuperStrict

Framework brl.standardio
Import pub.freeprocess

?Win32

	'Lets use OO for the hell of it, although you can use CreateProcess() if you prefer
	'There is only 1 flag available - HIDECONSOLE that is supposed to hide console output ;-) but it doesn't make much difference either way on my Windows machine
	Local temp_process:TProcess = TProcess.Create("ipconfig",HIDECONSOLE)
	
	Print ""
	Print "IPConfig Status: " + temp_process.Status()	'Show that the program is running
	Print "================================"
	
	While temp_process.Status()	'Checks to see if the process is still running
	
		Local tmpBytes:Byte[]
		
		'Check if the pipe contains any data that hasn't been read and if so, get available data
		If temp_process.pipe.ReadAvail() Then tmpBytes = temp_process.pipe.ReadPipe()
		
		For Local tmpByte:Byte = EachIn tmpBytes
				
			If Chr(tmpByte) <> "~n" Then tmpLine:+Chr$(tmpByte) Else Print tmpLine;tmpLine = ""
	
		Next 
		
	Wend
	
	If temp_process.pipe.ReadAvail() Then Print "Still bytes left 1"
	If Not temp_process.pipe.Eof() Then Print "Still bytes left 2"
	If temp_process.pipe.ReadPipe().length Then Print "Still bytes left 3"
	
	'Terminate process manually (the fact that is has escaped the above loop means it has already closed but put it in as an example)
	temp_process.Close()
	'This is a quick way you can terminate all processes without bothering to loop through them all (again not needed)
	TProcess.TerminateAll()
	
	Print "================================"
	Print "IPConfig Status: " + temp_process.Status()	'Show that the program has ended
	Print ""

?MacOs

	Print "Mac OS X doesn't have IpConfig."

?Linux

	Print "Linux doesn't have IpConfig."

?