I am attempting to read user input of strings that represent shell commands and execute those commands from Java. I have already seen that "cd" does not work (Exception in thread "main" java.io.IOException: Cannot run program "cd":) but this can be worked around. Similar for "export". I see now "echo" of an environment variable, set by providing arguments to exec, also does not work and I can't understand why "echo" would fail.
I would like to know in particular why "echo" does not work and in general what other commands will fail. If there is a broad category of such commands or if there are relatively few so that each can be worked around.
EDIT: I have a web UI and a textarea into which the user can enter multiple strings, each terminated by a newline. The program reads each string and then would like to execute each as a shell command or program, just as if the user had entered those commands at the command prompt. This seems to work for some user input using Runtime.exec but fails for other input.
EDIT: The other question which has an answer that answers my question seems to handle a single command, not a series of commands, one of which might affect subsequent commands. How does one handle a sequence of multiple commands?