Getting a string from standardio
BlitzMax Forums/BlitzMax Programming/Getting a string from standardio
| ||
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 |
| ||
Take a look at the PUB.FreeProcess module. |
| ||
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) |
| ||
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. |