I am running a script containing the following commands
#!/bin/bash
ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'
I have a java wrapper for executing this script using Runtime.exec(...). Running this java code works fine all the time.
The problem is when using running this java method under tomcat it give me an error
script.sh: line 3: ifconfig: command not found
Restarting the tomcat service the script runs perfectly for some time, after which this problem is again persists.
How do i solve this problem ?
EDIT : Java code :
String executableScript = <path to script>/script.sh;
String line;
String output;
String[] command = {executableScript};
Process process = Runtime.getRuntime().exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = input.readLine()) != null) {
output.append(line);
}
process.waitFor();
input.close();