struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keshav Shetty <Keshav.She...@eurodyn.com>
Subject Re: OT: Runtime exec (again)
Date Thu, 02 Dec 2004 09:20:30 GMT
May be cmd.exe is not available within the path when executing from tomcat.
Try to add full path and try.
Alternatively find out what is the message returned when cmd.exe is 
executed within the tomcat(Not the return code).
You can display this message using following code.

    exitValue = proc.waitFor();
    BufferedInputStream is = new BufferedInputStream(proc.getInputStream());
    java.lang.System.out.println("Printing output rom the consle");       
    while (is.available() > 0) {
            java.lang.System.out.print((char)is.read());
    }

Thanks & regards
Keshav K Shetty

andy wix wrote:

> 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. I have also tried the Tomcat list to no avail.
>
> 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
>
> _________________________________________________________________
> It's fast, it's easy and it's free. Get MSN Messenger today! 
> http://www.msn.co.uk/messenger
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Mime
View raw message