0

I am developing an application that will run a command line application from a Java interface. This app used to work on my fedora but now under Ubuntu I get this message:

Error opening terminal: unknown.

I am starting the application using this command:

 Process clientProcess = Runtime.getRuntime().exec(clientcommand);

where clientcommand is a string that contains the command to be run. also please note that when I copy and paste the command directly to the console the program runs as supposed.What am I doing wrong? is there an issue with running a command this way?

4
  • when I copy and paste the command dirrectly to the console the program runs as supposed could mean, that you use commands which only work in a shell. Invoking the shell would be needed then. Does the line fail with every command? Commented Mar 21, 2011 at 22:33
  • Are you capturing stdout and stderr from the Process? If so, does anything get output to either? If not, try doing that and seeing if there's anything that helps. Also valuable might be the exit value. Commented Mar 21, 2011 at 22:46
  • If clientcommand is a string and contains spaces or escape sequences then it problably doesn't work as expected. Try using an array instead. Commented Mar 22, 2011 at 5:36
  • this command in not working only in shell because when I remove the additional command line parameters it runs fine. @Rob Hruska yes I am capruting the input and error streams the error is the above mentioned (Error opening terminal:unknown) the exit value is 1 @Thomas Mueller I have changed to array but no luck. Commented Mar 22, 2011 at 22:30

1 Answer 1

1

I know why this is happening, but I may not have a solution for you. But lets see...

I had this same problem on OSX. I was running .sh scripts form Jenkins. I would get this error. It turns out the issue is it doesn't know where or which terminal you want to use. Since Jenkins was sudo'ing as me, i went to my .bashrc and defined export TERM=xterm . That did the trick.

So now i have a situation where I'm developing a grails app and the same problem is occurring... but i dont know how to set the xterm for grails... as it isn't running as me.

But anyway, the issue is your system doesn't know which terminal to use... or how to reach it. By specifying your terminal it should work.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.