author action for executing commands/scripts

Post here questions and problems related to oXygen frameworks/document types.
xephon
Posts: 95
Location: Hamburg/Germany

author action for executing commands/scripts

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: 5132

Re: author action for executing commands/scripts

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: 95
Location: Hamburg/Germany

Re: author action for executing commands/scripts

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: 95
Location: Hamburg/Germany

Re: author action for executing commands/scripts

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: 5132

Re: author action for executing commands/scripts

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
Site Admin
Posts: 111

Re: author action for executing commands/scripts

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/18.1/ug-editor/topics/dg-default-author-operations.html.

All the best wishes,
Sorin Carbunaru
oXygen XML

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 1 guest