dcsimg
How to run batch files which is on UNIX OS using JAVABeans
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   pat_pat
Posted On:   Tuesday, January 28, 2003 02:06 PM

I have a batch files called dataimport.bat and which is place under web root, i am using OC4J , so web root as a folder called import under that dataimport.bat is place, so it like this: project/web/import/dataimport.bat i am using on Javabeans called ImportDAO.java Code is like: there is the method called createImport: public void createImport() throws SQLException { try { Process p = Runtime.getRuntime().exec("\import\dataimport.bat"); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader error = new BufferedReader(new InputStrea   More>>

I have a batch files called dataimport.bat and which is
place under web root, i am using OC4J , so web root as a

folder called import under that dataimport.bat is place,

so it like this:

project/web/import/dataimport.bat i am using on Javabeans
called ImportDAO.java


Code is like: there is the method called createImport:


public void createImport() throws SQLException {

try


{



Process p = Runtime.getRuntime().exec("\import\dataimport.bat");


BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));


BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream()));



String line;


while ((line = input.readLine()) != null)


{
System.out.println(line);
}



while ((line = error.readLine()) != null)


{
System.out.println(line);
}



input.close();


error.close();



p.waitFor();

p.destroy();



}


catch (Exception e)


{


String msg = "Error occured!" + e.toString();


System.out.println(msg);

}

}


When i am executing this i am getting IOException Error=2.


Any help greatly appreciated, Thanks in advance.

   <<Less

Re: How to run batch files which is on UNIX OS using JAVABeans

Posted By:   James_Bayer  
Posted On:   Tuesday, January 28, 2003 03:12 PM

I believe error code 2 means "File Not Found", so it is likely that the line:


Process p = Runtime.getRuntime().exec("\import\dataimport.bat");


is not resolving to a file correctly. on unix, you should be using "/" insteat of "" for File separators. try giving the absolute path to the the .bat file, and try it again. also, make sure that the .bat file has read and execute permissions for the user that is running the web server.
About | Sitemap | Contact