Murga-Projects Forums
os.execute - Printable Version

+- Murga-Projects Forums (
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: os.execute (/showthread.php?tid=322)

os.execute - asafp - 05-31-2008 11:30 AM

Is there a way to run a system command and receive the standard output in a variable? os.execute returns only a status code.

RE: os.execute - JohnMurga - 05-31-2008 02:06 PM


Another quick response from an internet cafe as I don't get back for another week ...

Effectively that is what the test_pid example does although it is a little cryptic.

I'll post updated code on here soon as I get a chance.


RE: os.execute - mikshaw - 06-02-2008 01:22 AM

There is also io.popen("my_command")

more specifically:

my_cmd=io.popen("my_command") -- runs command
my_result=my_cmd:read("*a") -- read output of command to a variable

RE: os.execute - asafp - 06-02-2008 07:44 AM

Thanks mikshaw. That worked like a charm.