Hi guys, Well, I just figured it out...turns out that when I run it as a standalone application, something like this works just fine:
File path = new File("C:/temp99"); String cmd = "test.bat"; Runtime.getRuntime().exec(cmd, null, path); When I run it in Tomcat, however, the cmd _must_ include the path, like this: File path = new File("C:/temp99"); String cmd = "C:/temp99/test.bat"; Runtime.getRuntime().exec(cmd, null, path); If I don't do this, it blows up. Is that wierd or what? What I can't figure out is that in both cases I am using the same JDK (1.3.1), so I'm not sure why the first example works standalone but not in a servlet. Wierd wierd wierd. Oh well, at least it works... *sigh* :-) Thanks for your everyone's help! Christian ---------------------------------------------- Christian Cryder [[EMAIL PROTECTED]] Internet Architect, ATMReports.com Barracuda - http://barracuda.enhydra.org ---------------------------------------------- "What a great time to be a(n employed) Geek" > -----Original Message----- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > he.org]On Behalf Of Christian Cryder > Sent: Friday, January 25, 2002 7:43 PM > To: Tomcat-User > Subject: Tomcat 4 & Runtime.exec()? > > > Can anyone tell me why the Runtime.exec() call in the following piece of > code runs fine standalone, but blows chunks in Tomcat 4? > > File path = new File("E:/WebProjects/lutris/cvs/Barracuda/src"); > String[] args = new String[] {"ant.bat","admin.sample1"}; > try { > Process p = Runtime.getRuntime().exec(args, null, path); > StringBuffer sbOut = new StringBuffer(1000); > BufferedReader br = new BufferedReader(new > InputStreamReader(p.getInputStream())); > while (true) { > String s = br.readLine(); > if (s==null) break; > System.out.println(s); > } > br.close(); > p.waitFor(); > System.out.println (sbOut.toString()); > System.out.println ("Exit status: "+p.exitValue()); > } catch (Exception e) { > System.out.println ("Unexpected error executing cmd:"+e); > } > > Like I said, it works fine when run as an application. But in > Tomcat, I get > the following stack trace: > > Path: E:\WebProjects\lutris\cvs\Barracuda\src (exists=true) > Args[0]: ant.bat > Args[1]: admin.sample1 > Unexpected error executing cmd:java.io.IOException: CreateProcess: ant.bat > admin.sample1 error=2 > java.io.IOException: CreateProcess: ant.bat admin.sample1 error=2 > at java.lang.Win32Process.create(Native Method) > at java.lang.Win32Process.<init>(Unknown Source) > at java.lang.Runtime.execInternal(Native Method) > at java.lang.Runtime.exec(Unknown Source) > ... > <snip> > ... > > Suggestions? Is there something I don't know about invoking Runtime.exec() > from with a servlet? > > Thanks, > Christian > ---------------------------------------------- > Christian Cryder [[EMAIL PROTECTED]] > Internet Architect, ATMReports.com > Barracuda - http://barracuda.enhydra.org > ---------------------------------------------- > "What a great time to be a(n employed) Geek" > > > -- > To unsubscribe: <mailto:[EMAIL PROTECTED]> > For additional commands: <mailto:[EMAIL PROTECTED]> > Troubles with the list: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>