I'm creating a Java library as the backend for a Tomcat web interface. The purpose of the library is to take arguments from the interface and use them to execute other commands on the system.
I know I can use Runtime.getRuntime().exec()
to send the command, but is there a way to identify what shell the commands are sent to?
I'd like to use syntax I know from BASH to direct stdout
to a target file, but I'm not sure if I'm in BASH, Bourne, or something else unique to the Java runtime.
Desired result: Shell flexibility. Detect when I can do
Runtime.getRuntime().exec(myCommand + " >> " + myTargetFile);
and when that would be an invalid operator.
EDIT: formatting