Getting a string from standardio

BlitzMax Forums/BlitzMax Programming/Getting a string from standardio

plash(Posted 2008) [#1]
I want to get the string echoed from a bash script (windows users can just post.Replace("bash", "batch") )..

I can see a pretty simple option: save the string into a file and just load it in BlitzMax.
However, that seems silly, can't we just delay all printing on standardio just before we execute the script and then readline the string?

Example code (Linux):
SuperStrict

Framework brl.StandardIO

system_("sh mtime.sh /home/tim/scripts/etc/getecho.bmx")
End


Script:
#!/bin/bash
#

MTIME=$(/bin/ls -lo "$@" | awk '{print $5,$6}')

echo $MTIME



grable(Posted 2008) [#2]
Take a look at the PUB.FreeProcess module.


plash(Posted 2008) [#3]
http://www.blitzbasic.com/codearcs/codearcs.php?code=1993

I assumed freeprocess was all messed up in Linux.. seems like it still is

SuperStrict

Framework brl.StandardIO
Import pub.freeprocess

Include "inc/types/tproc.bmx"


Local ex_proc:TProc = TProc.Create("sh mtime.sh /home/tim/scripts/etc/getecho.bmx")

While ex_proc.Eof() = False
	
	If ex_proc.Avail() Print "read: " + ex_proc.Read()
	
Wend
ex_proc.close()

End



(that doesn't work)


plash(Posted 2008) [#4]
None of the techniques here work either. The TProc code is just a wrapper that does the same thing anyways.

Using a long delay after the loop before checking for data in the pipe doesn't work either.