Hello All...
I am developing an application where i required to run some of the scripts of unix from Java Code.
Platform i am using is Unix, Tomcat 5.5..
For that, My Sample Code is as follows :
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("netstat -i|tail -n +3|cut -d ' ' -f1");
System.out.println("exitValue = "+proc.exitValue());
I have given all the rights to tomcat user.
Now, my program output cases are :
Script exitValue()
======= ============
netstat -i 0
netstat -i|tail -n +3 4
sudo netstat -i 1
sudo netstat -i|tail -n +3 1
Above table suggest that only 1st script is executing in unix, all others are failing.
I am not sure, but i am just assuming that i have to run Tomcat Server as a root user..
Can anybody have any other solution, then please reply..
Thanks in advance...