Re: Start Programms out of the Wiki
Murray Altheim <[email protected]>
| Newsgroups | gmane.comp.java.jspwiki.user |
|---|---|
| Message-ID | <[email protected]> |
Tracer7 wrote:
> Hallo
>
> Is there a way or a plug in with which you can start a
> external Programm out of the Wiki ?
> There is a way to open external Files, with a link
> like :
> [open File|http://example.org/resource]
>
> But how can you start an external programm out of the Wiki ?
Well, it'd be a really really really really bad idea to permit a
public wiki to open a local program. Bad enough with spam, much
less them opening applications on the server. I'd just sooner
shoot myself in the head with a explosive-tipped harpoon.
But if you are running a local wiki and want to do this kind
of thing, you could do it via scripting if you can get access
to the local environment. You normally can't (and for good
reason) with Tomcat, but there is a way: you'd either Groovy
(e.g., the GroovyPlugin) to open a Java-based external process
outside of the normal sandboxed environment, like running a
bash script in unix/linux.
I've not got the time to guide you through the entirety of this,
but if you installed the GroovyPlugin and combined that with
something like the following, you may be able to get it working:
/**
* Runs an application on the String <tt>s</tt> as if it had been
* typed on the command line. The stdout and stderr result of this
* can be obtained from {@link #getStdout()} and {@link #getStderr()}.
*/
public void commandLine( String s )
{
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(s);
// handle stdout and stderr in own thread so as not to block
StdLogWriter slog = new StdLogWriter(proc);
slog.start();
} catch ( Exception e ) {
System.err.println(e.getClass().getName() + " thrown running \""
+ s + "\" on command line: " + e.getMessage() );
e.printStackTrace(System.err);
} finally {
// anything?
}
}
/** Low priority thread to log stdout and stderr sent
* from command line to the class-level buffers. */
private class StdLogWriter extends Thread
{
// [left as an exercise for the reader...]
}
Happy experimenting!
Murray
...........................................................................
Murray Altheim <murray07 at altheim.com> === = =
http://www.altheim.com/murray/ = = ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk = = = =
Boundless wind and moon - the eye within eyes,
Inexhaustible heaven and earth - the light beyond light,
The willow dark, the flower bright - ten thousand houses,
Knock at any door - there's one who will respond.
-- The Blue Cliff Record