author action for executing commands/scripts

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

author action for executing commands/scripts

Post by xephon »

Hi,

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

Greetings,
Stefan
stefan-jung.org – Your DITA/DITA-OT XML consultant
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Re: author action for executing commands/scripts

Post by Radu »

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: 140
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: author action for executing commands/scripts

Post by xephon »

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
stefan-jung.org – Your DITA/DITA-OT XML consultant
xephon
Posts: 140
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: author action for executing commands/scripts

Post by xephon »

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
stefan-jung.org – Your DITA/DITA-OT XML consultant
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Re: author action for executing commands/scripts

Post by Radu »

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: 402
Joined: Mon May 09, 2016 9:37 am

Re: author action for executing commands/scripts

Post by sorin_carbunaru »

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