Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Capturing output from operating system commands

Capturing output from operating system commands

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Tue 07 Dec 2004 09:09 PM (UTC)
Message
I had this code in another thread, but it was a bit hard to find, so I'll put it here in the Lua section.

Here is an example of executing an operating system command, and capturing the output.


-- get a temporary file name
n = os.tmpname ()

-- execute a command
os.execute ("dir > " .. n)

-- display output
for line in io.lines (n) do
  print (line)
end

-- remove temporary file
os.remove (n)




- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #1 on Wed 08 Dec 2004 09:38 PM (UTC)
Message
I found an ActiveX control to do that, tell me if anyone wants it (can't remember the name at the moment). Does the program have to stop for this lua code to work, or can it do it as it's running?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 08 Dec 2004 09:43 PM (UTC)
Message
Still trying to get the chess game to work, eh?

In this case, it runs the command and exits. Conceivably you might do it with piping, but that isn't enabled right now. Plus, I doubt it a bit.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #3 on Wed 08 Dec 2004 09:50 PM (UTC)
Message
I tried piping, it doesn't work. The chess system runs great with that ActiveX control (if only Crafty had coordinate notation, aaargh).

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 08 Dec 2004 09:55 PM (UTC)
Message
Here's a suggestion - write your own chess game in Lua. ;)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #5 on Thu 09 Dec 2004 12:06 AM (UTC)
Message
I'm not trying to make a game, I'm trying to get the engine (the AI) to work, which I did with that control. I still haven't learned Lua :P

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


18,529 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.