News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
os.execute
Author Message
asafp
Member
***


Posts: 81
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #1
os.execute

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

05-31-2008 11:30 AM
Visit this user's website Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #2
RE: os.execute

Hey

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.

Cheers
JohnM

05-31-2008 02:06 PM
Visit this user's website Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #3
RE: os.execute

There is also io.popen("my_command")

more specifically:

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

This post was last modified: 06-02-2008 01:24 AM by mikshaw.

06-02-2008 01:22 AM
Find all posts by this user Quote this message in a reply
asafp
Member
***


Posts: 81
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #4
RE: os.execute

Thanks mikshaw. That worked like a charm.

06-02-2008 07:44 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: