tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allistair Crossley" <Allistair.Cross...@QAS.com>
Subject RE: Runtime exec (again)
Date Thu, 02 Dec 2004 09:44:33 GMT
Hi,

I can't test this because shutdown is only a command on Windows XP it seems ... that's what
you're running right?

I did however try ipconfig and that works ..

<%
	try {
		Runtime runtime = Runtime.getRuntime();
		Process proc = runtime.exec("cmd.exe /C ipconfig");
		int exitVal = proc.waitFor();
		
		BufferedInputStream bis = new BufferedInputStream(proc.getInputStream());
		byte[] streamBuffer = new byte[4096];
		int byteRead = -1;
		while ((byteRead = bis.read(streamBuffer)) > - 1) {
			out.print(new String(streamBuffer, 0, byteRead)); 
		}
	} catch (Exception e) {
		System.out.println(e.getMessage());
	}
%>

I can have a look when I get home tonight on my XP machine if you have not sorted it by then.


Cheers, Allistair.

> -----Original Message-----
> From: andy wix [mailto:stixwix@hotmail.com]
> Sent: 02 December 2004 09:12
> To: tomcat-user@jakarta.apache.org
> Subject: Runtime exec (again)
> 
> 
> Hi,
> 
> Still can't get this to work.
> 
> There must be some reason why this won't run under Tomcat but 
> does work 
> stand-alone.
> To recap, I am trying to execute the following code on an Xp 
> box with Tomcat 
> 5.0.27:
> 
> Process proc = runtime.exec("cmd.exe /C shutdown -r -f -m 
> \\myPC -t 50");
> int exitVal = proc.waitFor();
> 
> When this runs the proc exits with a value of 0 but nothing 
> happens (no 
> re-boot) and no exceptions are thrown.
> 
> I have tried running the code from a batch file and without 
> the cmd.exe /C 
> bit.
> 
> I have tried running Tomcat from the command line (not as service).
> 
> I have tried allowing all permissions in the catalina.policy file:
> grant codeBase 
"file:${catalina.home}/webapps/ROOT/WEB-INF/classes/-" {
   permission java.security.AllPermission "*";
};

I CAN successfully set the the system time and date using the same approach
though.

I have absolutely no idea on this now.

Thanks,
Andy

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> 
-------------------------------------------------------
QAS Ltd.
Developers of QuickAddress Software
<a href="http://www.qas.com">www.qas.com</a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message