Page 1 of 1

author action for executing commands/scripts

Posted: Tue Sep 06, 2016 1:29 pm
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

Re: author action for executing commands/scripts

Posted: Tue Sep 06, 2016 2:15 pm
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

Re: author action for executing commands/scripts

Posted: Tue Sep 06, 2016 6:37 pm
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

Re: author action for executing commands/scripts

Posted: Thu Sep 08, 2016 11:03 am
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

Re: author action for executing commands/scripts

Posted: Thu Sep 08, 2016 12:09 pm
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

Re: author action for executing commands/scripts

Posted: Thu Oct 20, 2016 3:31 pm
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