Murga-Projects Forums
possible to use io.popen? - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: possible to use io.popen? (/showthread.php?tid=10)


possible to use io.popen? - mikshaw - 04-26-2007 03:41 PM

Lua has this handy alternative to os.execute which grabs the output of a shell command:

mycmd = io.popen("some_command")
myoutput = mycmd:read("*a")
mycmd:close()

Is this possible with MurgaLua? If not, is there something similar which doesn't require writing the command's output to a file and then parsing the file?

Thanks for reading.


RE: possible to use io.popen? - JohnMurga - 04-26-2007 07:23 PM

mikshaw Wrote:
Lua has this handy alternative to os.execute which grabs the output of a shell command:

mycmd = io.popen("some_command")
myoutput = mycmd:read("*a")
mycmd:close()


Hi mikshaw !

I did some research and it turns out that this is disabled when you build Lua in ANSI mode (for compatibility), however popen works on the three platforms I am interested in so I have tweaked the build and it'll be available along with a couple of other things when I update 0.4 (this week?).

Cheers
JohnM


RE: possible to use io.popen? - mikshaw - 04-27-2007 02:48 AM

Thank you! I know there will be other people pleased with this feature as well.