dcsimg
To Invoke a shell script from the java program In Solaris Platform
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Guna_Seelan
Posted On:   Wednesday, April 4, 2001 12:27 AM

hi to all , i installed jdk in the solaris. i've written one shell script and one java pgm. while i'm executing the java class file i would like to invoke the shell scirpt available in the same directory. but its not possible to get the output. if i run the same pgm in NT i can easily call any exe file like notepad.exe , calc.exe etc. In solaris not out put. if anyone got the query feel free to answer. /* The Codings r */ /* fscprt */ echo " hi this is the first scipt in solaris " /* ******** */ /* Java Codings r */ public class ExecScrpt { public static void main(String args[]) { Runtime r = Runtime.getRuntime(); Process p = nul   More>>

hi to all ,

i installed jdk in the solaris. i've written one shell script and one java pgm. while i'm executing the java class file i would like to invoke the shell scirpt available in the same directory. but its not possible to get the output.

if i run the same pgm in NT i can easily call any exe file like notepad.exe , calc.exe etc. In solaris not out put. if anyone got the query feel free to answer.

			
/* The Codings r */
/* fscprt */
echo " hi this is the first scipt in solaris "
/* ******** */
/* Java Codings r */
public class ExecScrpt
{
public static void main(String args[])
{
Runtime r = Runtime.getRuntime();
Process p = null;

try
{
p =r.exec("fscrpt");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

/*************************************/

if u try to run the above no output.

but In NT if put
			
r.exec("notepad")

instead of
			
r.exec("fscprt")

it will open a new notepad ie that exe file will easily be called.

note :
i gave executable permission for that script called fscrpt also.


do reply if u got it.

bye ,

Guna.    <<Less

Re: To Invoke a shell script from the java program In Solaris Platform

Posted By:   Sairam_Krishna  
Posted On:   Wednesday, August 29, 2001 12:39 PM

Hi,



Get the InputStream from your process using getInputStream method of the process you are running.

Pass this to an InputStreamReader

Pass this to a BufferedReader.

From the BufferedReader, use the method readLine() to capture the standard output of your shell script.




Also, check the permission of the shell script. Give full permissions to the file.

Re: To Invoke a shell script from the java program In Solaris Platform

Posted By:   Tim_Rohaly  
Posted On:   Friday, April 20, 2001 04:06 PM

Please read the API documentation for java.lang.Process.
You're not capturing standard output - the script is
running, you just are losing the output.
About | Sitemap | Contact