You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mohammed Sanaulla <sa...@gmail.com> on 2010/09/05 21:13:08 UTC
[exec] Getting Error opening terminal error while trying to execute
command on linux
Hi all,
I have recently started to use Exec. I was trying to execute "proz" command
(Command for Prozilla) on Linux using the CommandLine and DefaultExecutor as
an asynchronous process. When ever I try to run the program I get the
following error: Error opening terminal: unknown.
And the code terminates with Exit Value=1.
I did a bit of research to find out that- its not able to determine the type
of terminal. So there were solutions to set the value of $TERM with the
value obtained from "echo $TERM" (which in my case is xterm). I had a look
at the EnvironmentUtils class and tried to use it to set the value of $TERM
before executing the command. I used the following to set it:
Map environment = EnvironmentUtils.getProcEnvironment();
EnvironmentUtils.addVariableToEnvironment(EnvironmentUtils.getProcEnvironment(),"TERM=xterm");
But am not able to set the env variable. Any idea what's going wrong in both
the places (executing the command and setting the env variable)
Regards,
Mohamed Sanaulla
Re: [exec] Getting Error opening terminal error while trying to execute
command on linux
Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Mohammed,
I will have a look at it and put the stuff into a regression test
Cheers,
Siegfried Goeschl
On 9/6/10 8:40 AM, Mohammed Sanaulla wrote:
> On 6 September 2010 02:02, Siegfried Goeschl
> <si...@it20one.at>wrote:
>
>> Hi Mohamed,
>>
>> can you have a look at DefaultExecutorTest#testExecuteWithEnv() to check
>> what's missing or wrong -
>> http://commons.apache.org/exec/xref-test/org/apache/commons/exec/DefaultExecutorTest.html
>>
>>
> I see that the existing Environment variables from the current Process arent
> being copied instead only a new variable is being added (lines- 145,146)
>
> I did the following in my Code:
> Map myEnvVars = new HashMap();
> myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
> myEnvVars.put("NEW_VAR","NEW_VAL");
>
> Regards,
> Mohamed Sanaulla.
>
>
>>
>> On 9/5/10 10:09 PM, Mohammed Sanaulla wrote:
>>
>>> I was able to execute the command. I got the environment variable map from
>>> the EnvironmentUtils and then added a new entry for TERM and then passed
>>> this Map along with execute() method of the DefaultExecutor.
>>>
>>> -
>>> Mohamed Sanaulla
>>>
>>> On 6 September 2010 00:43, Mohammed Sanaulla<sa...@gmail.com>
>>> wrote:
>>>
>>> Hi all,
>>>> I have recently started to use Exec. I was trying to execute "proz"
>>>> command
>>>> (Command for Prozilla) on Linux using the CommandLine and DefaultExecutor
>>>> as
>>>> an asynchronous process. When ever I try to run the program I get the
>>>> following error: Error opening terminal: unknown.
>>>>
>>>> And the code terminates with Exit Value=1.
>>>>
>>>> I did a bit of research to find out that- its not able to determine the
>>>> type of terminal. So there were solutions to set the value of $TERM with
>>>> the
>>>> value obtained from "echo $TERM" (which in my case is xterm). I had a
>>>> look
>>>> at the EnvironmentUtils class and tried to use it to set the value of
>>>> $TERM
>>>> before executing the command. I used the following to set it:
>>>>
>>>> Map environment = EnvironmentUtils.getProcEnvironment();
>>>>
>>>>
>>>> EnvironmentUtils.addVariableToEnvironment(EnvironmentUtils.getProcEnvironment(),"TERM=xterm");
>>>>
>>>> But am not able to set the env variable. Any idea what's going wrong in
>>>> both the places (executing the command and setting the env variable)
>>>>
>>>> Regards,
>>>> Mohamed Sanaulla
>>>>
>>>>
>>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [exec] Getting Error opening terminal error while trying to
execute command on linux
Posted by Mohammed Sanaulla <sa...@gmail.com>.
Siegfried,
Thanks a lot.
Regards,
On 14 September 2010 01:28, Siegfried Goeschl
<si...@it20one.at>wrote:
> Hi Mohammed,
>
> added the following test
>
> /**
> * Call a script to dump the environment variables of the subprocess
> * after adding a custom environment variable.
> *
> * @throws Exception the test failed
> */
> public void testAddEnvironmentVariables() throws Exception {
>
> Map myEnvVars = new HashMap();
> myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
> myEnvVars.put("NEW_VAR","NEW_VAL");
> exec.execute(new CommandLine(environmentSript), myEnvVars);
> String environment = baos.toString().trim();
> assertTrue(environment.contains("NEW_VAR"));
> }
>
> and it works
>
> Cheers,
>
> Siegfried Goeschl
>
>
> On 9/6/10 8:40 AM, Mohammed Sanaulla wrote:
>
>>
>>
>>
>> On 6 September 2010 02:02, Siegfried Goeschl
>> <siegfried.goeschl@it20one.at <ma...@it20one.at>>
>> wrote:
>>
>> Hi Mohamed,
>>
>> can you have a look at DefaultExecutorTest#testExecuteWithEnv() to
>> check what's missing or wrong -
>>
>> http://commons.apache.org/exec/xref-test/org/apache/commons/exec/DefaultExecutorTest.html
>>
>> I see that the existing Environment variables from the current Process
>> arent being copied instead only a new variable is being added (lines-
>> 145,146)
>>
>> I did the following in my Code:
>> Map myEnvVars = new HashMap();
>> myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
>> myEnvVars.put("NEW_VAR","NEW_VAL");
>>
>> Regards,
>> Mohamed Sanaulla.
>>
>>
>>
>> On 9/5/10 10:09 PM, Mohammed Sanaulla wrote:
>>
>> I was able to execute the command. I got the environment
>> variable map from
>> the EnvironmentUtils and then added a new entry for TERM and
>> then passed
>> this Map along with execute() method of the DefaultExecutor.
>>
>> -
>> Mohamed Sanaulla
>>
>> On 6 September 2010 00:43, Mohammed
>> Sanaulla<sanaulla123@gmail.com <ma...@gmail.com>>
>>
>> wrote:
>>
>> Hi all,
>> I have recently started to use Exec. I was trying to execute
>> "proz" command
>> (Command for Prozilla) on Linux using the CommandLine and
>> DefaultExecutor as
>> an asynchronous process. When ever I try to run the program
>> I get the
>> following error: Error opening terminal: unknown.
>>
>> And the code terminates with Exit Value=1.
>>
>> I did a bit of research to find out that- its not able to
>> determine the
>> type of terminal. So there were solutions to set the value
>> of $TERM with the
>> value obtained from "echo $TERM" (which in my case is
>> xterm). I had a look
>> at the EnvironmentUtils class and tried to use it to set the
>> value of $TERM
>> before executing the command. I used the following to set it:
>>
>> Map environment = EnvironmentUtils.getProcEnvironment();
>>
>>
>> EnvironmentUtils.addVariableToEnvironment(EnvironmentUtils.getProcEnvironment(),"TERM=xterm");
>>
>> But am not able to set the env variable. Any idea what's
>> going wrong in
>> both the places (executing the command and setting the env
>> variable)
>>
>> Regards,
>> Mohamed Sanaulla
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> <ma...@commons.apache.org>
>>
>> For additional commands, e-mail: user-help@commons.apache.org
>> <ma...@commons.apache.org>
>>
>>
>>
Re: [exec] Getting Error opening terminal error while trying to execute
command on linux
Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Mohammed,
added the following test
/**
* Call a script to dump the environment variables of the subprocess
* after adding a custom environment variable.
*
* @throws Exception the test failed
*/
public void testAddEnvironmentVariables() throws Exception {
Map myEnvVars = new HashMap();
myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
myEnvVars.put("NEW_VAR","NEW_VAL");
exec.execute(new CommandLine(environmentSript), myEnvVars);
String environment = baos.toString().trim();
assertTrue(environment.contains("NEW_VAR"));
}
and it works
Cheers,
Siegfried Goeschl
On 9/6/10 8:40 AM, Mohammed Sanaulla wrote:
>
>
>
> On 6 September 2010 02:02, Siegfried Goeschl
> <siegfried.goeschl@it20one.at <ma...@it20one.at>> wrote:
>
> Hi Mohamed,
>
> can you have a look at DefaultExecutorTest#testExecuteWithEnv() to
> check what's missing or wrong -
> http://commons.apache.org/exec/xref-test/org/apache/commons/exec/DefaultExecutorTest.html
>
> I see that the existing Environment variables from the current Process
> arent being copied instead only a new variable is being added (lines-
> 145,146)
>
> I did the following in my Code:
> Map myEnvVars = new HashMap();
> myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
> myEnvVars.put("NEW_VAR","NEW_VAL");
>
> Regards,
> Mohamed Sanaulla.
>
>
>
> On 9/5/10 10:09 PM, Mohammed Sanaulla wrote:
>
> I was able to execute the command. I got the environment
> variable map from
> the EnvironmentUtils and then added a new entry for TERM and
> then passed
> this Map along with execute() method of the DefaultExecutor.
>
> -
> Mohamed Sanaulla
>
> On 6 September 2010 00:43, Mohammed
> Sanaulla<sanaulla123@gmail.com <ma...@gmail.com>>
> wrote:
>
> Hi all,
> I have recently started to use Exec. I was trying to execute
> "proz" command
> (Command for Prozilla) on Linux using the CommandLine and
> DefaultExecutor as
> an asynchronous process. When ever I try to run the program
> I get the
> following error: Error opening terminal: unknown.
>
> And the code terminates with Exit Value=1.
>
> I did a bit of research to find out that- its not able to
> determine the
> type of terminal. So there were solutions to set the value
> of $TERM with the
> value obtained from "echo $TERM" (which in my case is
> xterm). I had a look
> at the EnvironmentUtils class and tried to use it to set the
> value of $TERM
> before executing the command. I used the following to set it:
>
> Map environment = EnvironmentUtils.getProcEnvironment();
>
> EnvironmentUtils.addVariableToEnvironment(EnvironmentUtils.getProcEnvironment(),"TERM=xterm");
>
> But am not able to set the env variable. Any idea what's
> going wrong in
> both the places (executing the command and setting the env
> variable)
>
> Regards,
> Mohamed Sanaulla
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> <ma...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
> <ma...@commons.apache.org>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [exec] Getting Error opening terminal error while trying to execute
command on linux
Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Mohammed,
I will have a look at it and put the stuff into a regression test
Cheers,
Siegfried Goeschl
On 9/6/10 8:40 AM, Mohammed Sanaulla wrote:
> On 6 September 2010 02:02, Siegfried Goeschl
> <si...@it20one.at>wrote:
>
>> Hi Mohamed,
>>
>> can you have a look at DefaultExecutorTest#testExecuteWithEnv() to check
>> what's missing or wrong -
>> http://commons.apache.org/exec/xref-test/org/apache/commons/exec/DefaultExecutorTest.html
>>
>>
> I see that the existing Environment variables from the current Process arent
> being copied instead only a new variable is being added (lines- 145,146)
>
> I did the following in my Code:
> Map myEnvVars = new HashMap();
> myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
> myEnvVars.put("NEW_VAR","NEW_VAL");
>
> Regards,
> Mohamed Sanaulla.
>
>
>>
>> On 9/5/10 10:09 PM, Mohammed Sanaulla wrote:
>>
>>> I was able to execute the command. I got the environment variable map from
>>> the EnvironmentUtils and then added a new entry for TERM and then passed
>>> this Map along with execute() method of the DefaultExecutor.
>>>
>>> -
>>> Mohamed Sanaulla
>>>
>>> On 6 September 2010 00:43, Mohammed Sanaulla<sa...@gmail.com>
>>> wrote:
>>>
>>> Hi all,
>>>> I have recently started to use Exec. I was trying to execute "proz"
>>>> command
>>>> (Command for Prozilla) on Linux using the CommandLine and DefaultExecutor
>>>> as
>>>> an asynchronous process. When ever I try to run the program I get the
>>>> following error: Error opening terminal: unknown.
>>>>
>>>> And the code terminates with Exit Value=1.
>>>>
>>>> I did a bit of research to find out that- its not able to determine the
>>>> type of terminal. So there were solutions to set the value of $TERM with
>>>> the
>>>> value obtained from "echo $TERM" (which in my case is xterm). I had a
>>>> look
>>>> at the EnvironmentUtils class and tried to use it to set the value of
>>>> $TERM
>>>> before executing the command. I used the following to set it:
>>>>
>>>> Map environment = EnvironmentUtils.getProcEnvironment();
>>>>
>>>>
>>>> EnvironmentUtils.addVariableToEnvironment(EnvironmentUtils.getProcEnvironment(),"TERM=xterm");
>>>>
>>>> But am not able to set the env variable. Any idea what's going wrong in
>>>> both the places (executing the command and setting the env variable)
>>>>
>>>> Regards,
>>>> Mohamed Sanaulla
>>>>
>>>>
>>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [exec] Getting Error opening terminal error while trying to
execute command on linux
Posted by Mohammed Sanaulla <sa...@gmail.com>.
On 6 September 2010 02:02, Siegfried Goeschl
<si...@it20one.at>wrote:
> Hi Mohamed,
>
> can you have a look at DefaultExecutorTest#testExecuteWithEnv() to check
> what's missing or wrong -
> http://commons.apache.org/exec/xref-test/org/apache/commons/exec/DefaultExecutorTest.html
>
>
I see that the existing Environment variables from the current Process arent
being copied instead only a new variable is being added (lines- 145,146)
I did the following in my Code:
Map myEnvVars = new HashMap();
myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
myEnvVars.put("NEW_VAR","NEW_VAL");
Regards,
Mohamed Sanaulla.
>
> On 9/5/10 10:09 PM, Mohammed Sanaulla wrote:
>
>> I was able to execute the command. I got the environment variable map from
>> the EnvironmentUtils and then added a new entry for TERM and then passed
>> this Map along with execute() method of the DefaultExecutor.
>>
>> -
>> Mohamed Sanaulla
>>
>> On 6 September 2010 00:43, Mohammed Sanaulla<sa...@gmail.com>
>> wrote:
>>
>> Hi all,
>>> I have recently started to use Exec. I was trying to execute "proz"
>>> command
>>> (Command for Prozilla) on Linux using the CommandLine and DefaultExecutor
>>> as
>>> an asynchronous process. When ever I try to run the program I get the
>>> following error: Error opening terminal: unknown.
>>>
>>> And the code terminates with Exit Value=1.
>>>
>>> I did a bit of research to find out that- its not able to determine the
>>> type of terminal. So there were solutions to set the value of $TERM with
>>> the
>>> value obtained from "echo $TERM" (which in my case is xterm). I had a
>>> look
>>> at the EnvironmentUtils class and tried to use it to set the value of
>>> $TERM
>>> before executing the command. I used the following to set it:
>>>
>>> Map environment = EnvironmentUtils.getProcEnvironment();
>>>
>>>
>>> EnvironmentUtils.addVariableToEnvironment(EnvironmentUtils.getProcEnvironment(),"TERM=xterm");
>>>
>>> But am not able to set the env variable. Any idea what's going wrong in
>>> both the places (executing the command and setting the env variable)
>>>
>>> Regards,
>>> Mohamed Sanaulla
>>>
>>>
>>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
Re: [exec] Getting Error opening terminal error while trying to execute
command on linux
Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Mohamed,
can you have a look at DefaultExecutorTest#testExecuteWithEnv() to check
what's missing or wrong -
http://commons.apache.org/exec/xref-test/org/apache/commons/exec/DefaultExecutorTest.html
Cheers,
Siegfried Goeschl
On 9/5/10 10:09 PM, Mohammed Sanaulla wrote:
> I was able to execute the command. I got the environment variable map from
> the EnvironmentUtils and then added a new entry for TERM and then passed
> this Map along with execute() method of the DefaultExecutor.
>
> -
> Mohamed Sanaulla
>
> On 6 September 2010 00:43, Mohammed Sanaulla<sa...@gmail.com> wrote:
>
>> Hi all,
>> I have recently started to use Exec. I was trying to execute "proz" command
>> (Command for Prozilla) on Linux using the CommandLine and DefaultExecutor as
>> an asynchronous process. When ever I try to run the program I get the
>> following error: Error opening terminal: unknown.
>>
>> And the code terminates with Exit Value=1.
>>
>> I did a bit of research to find out that- its not able to determine the
>> type of terminal. So there were solutions to set the value of $TERM with the
>> value obtained from "echo $TERM" (which in my case is xterm). I had a look
>> at the EnvironmentUtils class and tried to use it to set the value of $TERM
>> before executing the command. I used the following to set it:
>>
>> Map environment = EnvironmentUtils.getProcEnvironment();
>>
>> EnvironmentUtils.addVariableToEnvironment(EnvironmentUtils.getProcEnvironment(),"TERM=xterm");
>>
>> But am not able to set the env variable. Any idea what's going wrong in
>> both the places (executing the command and setting the env variable)
>>
>> Regards,
>> Mohamed Sanaulla
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [exec] Getting Error opening terminal error while trying to
execute command on linux
Posted by Mohammed Sanaulla <sa...@gmail.com>.
I was able to execute the command. I got the environment variable map from
the EnvironmentUtils and then added a new entry for TERM and then passed
this Map along with execute() method of the DefaultExecutor.
-
Mohamed Sanaulla
On 6 September 2010 00:43, Mohammed Sanaulla <sa...@gmail.com> wrote:
> Hi all,
> I have recently started to use Exec. I was trying to execute "proz" command
> (Command for Prozilla) on Linux using the CommandLine and DefaultExecutor as
> an asynchronous process. When ever I try to run the program I get the
> following error: Error opening terminal: unknown.
>
> And the code terminates with Exit Value=1.
>
> I did a bit of research to find out that- its not able to determine the
> type of terminal. So there were solutions to set the value of $TERM with the
> value obtained from "echo $TERM" (which in my case is xterm). I had a look
> at the EnvironmentUtils class and tried to use it to set the value of $TERM
> before executing the command. I used the following to set it:
>
> Map environment = EnvironmentUtils.getProcEnvironment();
>
> EnvironmentUtils.addVariableToEnvironment(EnvironmentUtils.getProcEnvironment(),"TERM=xterm");
>
> But am not able to set the env variable. Any idea what's going wrong in
> both the places (executing the command and setting the env variable)
>
> Regards,
> Mohamed Sanaulla
>
>