I am absolutely amazed that something which I thought was really
extended in terms of Struts relevance should arise the next day or so.
 Please look at http://wiki.apache.org/struts/StrutsSolutions and
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html for a
wonderfully done article called "When Runtime.exec() won't".  LOL

'Hope this helps.

Jack




On Thu, 25 Nov 2004 13:29:43 -0500, David G. Friedman
<[EMAIL PROTECTED]> wrote:
> Andy,
> 
> I tried your command (with extra debugging) on Struts 1.2.4, Tomcat 5.0.28,
> Windows XP Home Edition. Debugging returned the same error code 0 but I
> detected the following messages which clearly explained the problem on my
> configuration:
> 
> > The operation completed successfully.
> > A required privilege is not held by the client.
> > Command "cmd.exe /C shutdown -r -f -t 60", exit code: 0
> 
> So, this begs the question, what user (and permissions level) does your web
> application or web service run under on Windows XP?  Does it run as a
> service while you debug under you, an admin-level user?  I run Eclipse and
> Tomcat under myself, a non-privileged user.  It reduces the possibility of a
> web-based or e-mail based virus from getting into my system.  I just login
> as "admin" when I need to install anything (not very often).
> 
> Here is my Action's relevant java code:
> 
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>         String cmd = "cmd.exe /C shutdown -r -f -t 60";
>         Runtime runtime = Runtime.getRuntime();
>         Process p = runtime.exec(cmd);
>         InputStream is = p.getInputStream();
>         int it = 0;
>         while ( (it=is.read())> 0 ) {
>                 System.out.print( (char)it);
>         }
>         System.out.println("Command \"" + cmd +
>                 "\", exit code: " + p.exitValue());
>         p.destroy();
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> 
> Regards,
> David
> 
> 
> 
> -----Original Message-----
> From: Paul McCulloch [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 25, 2004 7:06 AM
> To: 'Struts Users Mailing List'
> Subject: RE: server shutdown
> 
> It looks like you are getting the return code from cmd, rather than
> shutdown. Could it be that the process you spawn doesn't have it's
> environment correctly set up - maybe it can't see shutdown?
> 
> I'd try 1) changing my call to exec to call shutdown, with a full path,
> directly rather than getting cmd to do it. 2) Call a batch file instead -
> have the batchfile echo the environment to a file 3)Try and get the Java
> process to create an interactive cmd for you (maybe cmd /k) - that way you
> can try various commands in the same context that the Java process can.
> 
> Paul
> 
> > -----Original Message-----
> > From: andy wix [mailto:[EMAIL PROTECTED]
> > Sent: 25 November 2004 11:47
> > To: [EMAIL PROTECTED]
> > Subject: OT: server shutdown
> >
> > Hi,
> >
> > I have a requirement to allow a privelidged user to
> > reboot the server(WinXP OS).
> >
> > I have code as follows:
> >
> > Runtime runtime = Runtime.getRuntime();
> > Process proc = runtime.exec("cmd.exe /C shutdown -r -f -t 10");
> > int exitVal = proc.waitFor();
> >
> > When called, the server does not shut down (although
> > I get the exit code of 0) but if I run the same
> > command from the XP 'run' window it works as expected.
> >
> > I don't think it can be an access rights thing as I can
> > use the same approach to set the system time and date
> > successfully.
> >
> > Any ideas?
> >
> > Thanks,
> > Andy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 


"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to