blitzmax and terminal

Archives Forums/Linux Discussion/blitzmax and terminal

ssdw(Posted 2011) [#1]
Hello everyone,

it is possible with blitzmax to use the terminal on linux?
I mean for example that the program can send to the terminal the command "lspci" .
and then get the output.

I'm a bad interpreter, sorry for that.

Thank you


BlitzSupport(Posted 2011) [#2]
I've been trying for about an hour, but I can't get it to work.

This works fine under Windows:

Local proc:TProcess = CreateProcess ("ipconfig.exe")

If proc
	
	While ProcessStatus (proc)

		While proc.pipe.ReadAvail ()
			Print proc.pipe.ReadLine ()
		Wend

	Wend
	
EndIf


... but fails on Linux, as the process terminates before all the output can be read:

Local proc:TProcess = CreateProcess ("ifconfig") ' Only changed exe name!

If proc
	
	While ProcessStatus (proc)

		While proc.pipe.ReadAvail ()
			Print proc.pipe.ReadLine ()
		Wend

	Wend
	
EndIf


The only way I can read all of the output is to do something like this:

Local proc:TProcess = CreateProcess ("ifconfig")

If proc
	
	Repeat
		Print proc.pipe.ReadLine ()
	Forever
	
EndIf


However, although you get all the output, this (unsurprisingly) crashes when the process exits! Adding a check for ProcessRunning (proc) before ReadLine still causes it to fail because the process again terminates before it can all be read.

Anyone else see a way around this? I'm assuming it's something to do with the way the process is launched under Linux, but have no idea how to fix it -- skidracer, are you out there?!