Is there any way to call an exe file from a celx script??

All about writing scripts for Celestia in Lua and the .cel system
Topic author
MARKS
Posts: 8
Joined: 11.03.2007
With us: 17 years 8 months
Location: Spain

Is there any way to call an exe file from a celx script??

Post #1by MARKS » 15.03.2008, 19:04

Hello all, I'm trying to use a matlab function to get an XYZ file and I'd like to call this function from a celx script. I've read lots of topics related with this issue, but I haven't got any answer to my question. So, if anybody can tell me any information about that, i'll be very grateful.
Sorry for my English.
Thank you all.

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: Is there any way to call an exe file from a celx script?

Post #2by Vincent » 16.03.2008, 11:28

MARKS,

You can use os.execute(filename) to run any filename from a celx script.

However, since this requires access to the Lua os library, you must first set ScriptSystemAccessPolicy to "allow" in celestia.cfg, and add the following lines at the beginning of your celx script:

Code: Select all

celestia:requestsystemaccess()
wait(0)


Then, if your .exe file is placed in a subfolder of the "Program Files" folder, I'd suggest to use a short batch file, such as:

Code: Select all

cd %ProgramFiles%\XYZFolder
XYZ.exe
Just replace XYZFolder and XYZ.exe with the names corresponding to your XYZ program.
You can save this batch file as "runXYZ.bat" in your celestia base folder.

Then, you'll be able to launch your XYZ program from your celx script using:

Code: Select all

os.execute("runXYZ")
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
MARKS
Posts: 8
Joined: 11.03.2007
With us: 17 years 8 months
Location: Spain

Post #3by MARKS » 25.03.2008, 18:04

Thank you Vincent for your answer, it works perfectly. :D

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Post #4by Vincent » 25.03.2008, 18:11

MARKS wrote:Thank you Vincent for your answer, it works perfectly. :D

You're welcome Marks.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3


Return to “Scripting”