my problem is simple, when I try to run .sh script from Java, the script doesnt execute. If I change my script to a simple linux command, such as ls -all, it works perfectly, so I guess that I am using a bad command in my script, which stops the execution. Please help.
David
Java code:
String cmd = "bash /home/david/burza/getter.sh";
try {
Process proc = Runtime.getRuntime().exec(new String[] {"/bin/sh", "-c", cmd});
BufferedReader read = new BufferedReader(new InputStreamReader(proc.getInputStream()));
try {
proc.waitFor();
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
while (read.ready()) {
System.out.println(read.readLine());
}
} catch (IOException e) {
System.out.println(e.getMessage());
}
Bash script:
#! /bin/bash
wget -O data1.html http://www.rmsystem.cz/kurzy-online/akcie/easyclick;
touch ext_data.txt;
grep 'table class="tbl1"' ./data1.html | tr '<td>' ' ' | tr '-' 'A' | grep -o -w '[0-9, ]*' | sed 's/ *//g' | sed '/^$/d' | tr ',' '.' > ext_data.txt;
lines=`wc -l ext_data.txt | grep -o '[0-9]*'`;
( echo $lines; cat ext_data.txt ) > ext_data.txt.new && mv ext_data.txt.new ext_data.txt;