author action for executing commands/scripts

Post here questions and problems related to oXygen frameworks/document types.
xephon
Posts: 100
Joined: Mon Nov 24, 2014 1:49 pm
Location: Münster/Germany

author action for executing commands/scripts

Post by xephon » Tue Sep 06, 2016 1:29 pm

Hi,

I wonder whether it is possible (and how) to execute a shell script and/or a command using an author action?

Greetings,
Stefan
Join the DOCTALES DITA development team :arrow: https://doctales.atlassian.net/wiki

Radu
Posts: 7212
Joined: Fri Jul 09, 2004 5:18 pm

Re: author action for executing commands/scripts

Post by Radu » Tue Sep 06, 2016 2:15 pm

Hi Stefan,

Oxygen 18.1 (Autumn this year) will come with a default author operation called ExecuteCommandLineOperation.
In the meantime maybe you can use a JSOperation with the following script which calls the Java Runtime API to start a process with a certain command line:

Code: Select all

function doOperation(){
Packages.java.lang.Runtime.getRuntime().exec("notepad.exe");
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

xephon
Posts: 100
Joined: Mon Nov 24, 2014 1:49 pm
Location: Münster/Germany

Re: author action for executing commands/scripts

Post by xephon » Tue Sep 06, 2016 6:37 pm

Hi Radu,

awesome :D This is a cool workaround, thanks a lot! :lol:

Glad to head, that <oXygen/> again evolves as I expect it to be. :)

Greetings,
Stefan
Join the DOCTALES DITA development team :arrow: https://doctales.atlassian.net/wiki

xephon
Posts: 100
Joined: Mon Nov 24, 2014 1:49 pm
Location: Münster/Germany

Re: author action for executing commands/scripts

Post by xephon » Thu Sep 08, 2016 11:03 am

Hi Radu,

for the new author operation, it would be nice, if you also could pass some variables, like ${pd} to call a command in a specific directory.

Greetings,
Stefan
Join the DOCTALES DITA development team :arrow: https://doctales.atlassian.net/wiki

Radu
Posts: 7212
Joined: Fri Jul 09, 2004 5:18 pm

Re: author action for executing commands/scripts

Post by Radu » Thu Sep 08, 2016 12:09 pm

Hi Stefan,

Yes, the operation will have 4 params: a name, a working directory, a command line and a flag which can be set if you want to see the console output in the Oxygen console view. And all params will accept editor variables.
The JSOperation equivalent is this one:

Code: Select all

function doOperation(){
//Execute a command line which opens the Notepad application
Packages.java.lang.Runtime.getRuntime().exec("notepad.exe", null, new Packages.java.io.File(new Packages.java.net.URL("${pdu}").toURI()));
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

sorin_carbunaru
Posts: 342
Joined: Mon May 09, 2016 9:37 am

Re: author action for executing commands/scripts

Post by sorin_carbunaru » Thu Oct 20, 2016 3:31 pm

Hello,

I am glad to confirm that, just as Radu already announced, the newly released oXygen 18.1 comes with a default Author operation called ExecuteCommandLineOperation, that can be used to run command lines. More information about the operation can be found at: https://www.oxygenxml.com/doc/versions/ ... tions.html.

All the best wishes,
Sorin Carbunaru
oXygen XML

Post Reply