Hi All,
i want to run shell script from java.shell script run successfully and generate a file.
But when i want to check the existence of that file,it shows that the file is not present.
please help me to check the file from java or how could i know the proccess(Shell script) is finished.
i have given my code below.
package com;
import java.io.*;
import java.util.*;
public class ScriptBuilder {
public ScriptBuilder() {
}
public void writeScript() throws java.io.IOExcep tion {
Runtime rt = Runtime.getRunt ime();
rt.exec("chmod 777 testinglinux.sh ");
Process p = rt.exec("./testinglinux.sh ");
try {
p.waitFor();
} catch (Exception e) {
e.printStackTra ce();
}
String shellfilename = "testing.tx t";
if (new File(shellfilen ame).exists()) {
System.out.prin tln(shellfilena me+" File exists");
}
}
public static void main(String[] args) throws java.io.IOExcep tion {
ScriptBuilder sb = new ScriptBuilder() ;
sb.writeScript( );
}
}
Thanks!
Vaskar
i want to run shell script from java.shell script run successfully and generate a file.
But when i want to check the existence of that file,it shows that the file is not present.
please help me to check the file from java or how could i know the proccess(Shell script) is finished.
i have given my code below.
package com;
import java.io.*;
import java.util.*;
public class ScriptBuilder {
public ScriptBuilder() {
}
public void writeScript() throws java.io.IOExcep tion {
Runtime rt = Runtime.getRunt ime();
rt.exec("chmod 777 testinglinux.sh ");
Process p = rt.exec("./testinglinux.sh ");
try {
p.waitFor();
} catch (Exception e) {
e.printStackTra ce();
}
String shellfilename = "testing.tx t";
if (new File(shellfilen ame).exists()) {
System.out.prin tln(shellfilena me+" File exists");
}
}
public static void main(String[] args) throws java.io.IOExcep tion {
ScriptBuilder sb = new ScriptBuilder() ;
sb.writeScript( );
}
}
Thanks!
Vaskar
Comment