Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » how to run bash script programmatically from eclipse plugin
how to run bash script programmatically from eclipse plugin [message #50747] Wed, 18 March 2009 14:06 Go to next message
sana is currently offline sanaFriend
Messages: 17
Registered: July 2009
Junior Member
Hi

how can i run bash script programmtically from eclipse plugin.
I tried using java runtime, but it does not work. The script is working
when called from command line or simple java application.

Runtime.getRuntime().exec(new String{"/home/script.sh","param1","param2"});

regards,
Sana.
Re: how to run bash script programmatically from eclipse plugin [message #50862 is a reply to message #50747] Wed, 18 March 2009 18:38 Go to previous messageGo to next message
Ankur Sharma is currently offline Ankur SharmaFriend
Messages: 84
Registered: July 2009
Member
Sana wrote:
Sana wrote:
> Hi
>
> how can i run bash script programmtically from eclipse plugin.
> I tried using java runtime, but it does not work. The script is working
> when called from command line or simple java application.
>
> Runtime.getRuntime().exec(new String{"/home/script.sh","param1","param2"});
>
> regards,
> Sana.
>

> Hi
>
> how can i run bash script programmtically from eclipse plugin.
> I tried using java runtime, but it does not work. The script is working
> when called from command line or simple java application.
>
> Runtime.getRuntime().exec(new String{"/home/script.sh","param1","param2"});
>
> regards,
> Sana.
>
From my experience on windows, you will probably have to prefix
"/bin/bash" before your command.

Runtime.getRuntime().exec(new String{"/bin/bash",
"/home/script.sh","param1","param2"});
Re: how to run bash script programmatically from eclipse plugin [message #51031 is a reply to message #50862] Thu, 19 March 2009 13:27 Go to previous messageGo to next message
sana is currently offline sanaFriend
Messages: 17
Registered: July 2009
Junior Member
Well, on linux, it does not seem to work. Infact ,if i ask for return
value of this subprocess, the process throws
java.lang.IllegalThreadStateException process has not exited.

try{
Runtime r = Runtime.getRuntime();
Process proc = r.exec(new
String{"/bin/sh","/home/script.sh","param1","param2"});
int exit_val = proc.exitValue();

}catch(Exception e){
e.printStackTrace();
}

thanks for any help,
Re: how to run bash script programmatically from eclipse plugin [message #51092 is a reply to message #51031] Thu, 19 March 2009 13:38 Go to previous message
Eclipse UserFriend
Originally posted by: clemens.froglogic.com

sana wrote:
> Well, on linux, it does not seem to work. Infact ,if i ask for return
> value of this subprocess, the process throws
> java.lang.IllegalThreadStateException process has not exited.

Hello.

The API documentation states that it behaves like that:

http://java.sun.com/javase/6/docs/api/java/lang/Process.html #exitValue()

Maybe add a call to waitFor() before calling exitValue().



With best regards

Clemens Anhuth


--
www.froglogic.com - Squish - Multi-Platform GUI Testing
Re: how to run bash script programmatically from eclipse plugin [message #593393 is a reply to message #50747] Wed, 18 March 2009 18:38 Go to previous message
Ankur Sharma is currently offline Ankur SharmaFriend
Messages: 84
Registered: July 2009
Member
Sana wrote:
Sana wrote:
> Hi
>
> how can i run bash script programmtically from eclipse plugin.
> I tried using java runtime, but it does not work. The script is working
> when called from command line or simple java application.
>
> Runtime.getRuntime().exec(new String{"/home/script.sh","param1","param2"});
>
> regards,
> Sana.
>

> Hi
>
> how can i run bash script programmtically from eclipse plugin.
> I tried using java runtime, but it does not work. The script is working
> when called from command line or simple java application.
>
> Runtime.getRuntime().exec(new String{"/home/script.sh","param1","param2"});
>
> regards,
> Sana.
>
From my experience on windows, you will probably have to prefix
"/bin/bash" before your command.

Runtime.getRuntime().exec(new String{"/bin/bash",
"/home/script.sh","param1","param2"});
Re: how to run bash script programmatically from eclipse plugin [message #593476 is a reply to message #50862] Thu, 19 March 2009 13:27 Go to previous message
sana is currently offline sanaFriend
Messages: 17
Registered: July 2009
Junior Member
Well, on linux, it does not seem to work. Infact ,if i ask for return
value of this subprocess, the process throws
java.lang.IllegalThreadStateException process has not exited.

try{
Runtime r = Runtime.getRuntime();
Process proc = r.exec(new
String{"/bin/sh","/home/script.sh","param1","param2"});
int exit_val = proc.exitValue();

}catch(Exception e){
e.printStackTrace();
}

thanks for any help,
Re: how to run bash script programmatically from eclipse plugin [message #593528 is a reply to message #51031] Thu, 19 March 2009 13:38 Go to previous message
Eclipse UserFriend
Originally posted by: clemens.froglogic.com

sana wrote:
> Well, on linux, it does not seem to work. Infact ,if i ask for return
> value of this subprocess, the process throws
> java.lang.IllegalThreadStateException process has not exited.

Hello.

The API documentation states that it behaves like that:

http://java.sun.com/javase/6/docs/api/java/lang/Process.html #exitValue()

Maybe add a call to waitFor() before calling exitValue().



With best regards

Clemens Anhuth


--
www.froglogic.com - Squish - Multi-Platform GUI Testing
Previous Topic:[Jade] Can't get a proxy to the Platform Manager
Next Topic:External Content Assist for all editors?
Goto Forum:
  


Current Time: Sat Jun 19 23:04:41 GMT 2021

Powered by FUDForum. Page generated in 0.02453 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top