Get error message from Command prompt
10 Message(s) by 6 Author(s) originally posted in java help
| From: christopher_board |
Date: Wednesday, October 24, 2007
|
Hi all.
I am currently trying to develop a JAVA applicatio that will enable me
to shutdown or restart computers remotely. I am doing this by using
the
command prompt
code in order to perform the shutdown. For example
I am using shutdown -m \\computer name -r -f -t 30.
When I
run this code in the command prompt and the computer cannot be
found on the
network it comes up with a
message saying that the
network
path wasn't found. How can I read in the
error message that
the command prompt provides from within my JAVA Application.
Any help in this matter'd be highly appreciated.
Thank you
| From: Andrew Thompson |
Date: Wednesday, October 24, 2007
|
wrote in message:
...
I am currently trying to develop a JAVA applicatio that will enable me
to shutdown or restart computers remotely. I am doing this by using
the command prompt code in order to perform the shutdown. For example
I am using shutdown -m \\computer name -r -f -t 30.
What does the Process returned from a Runtime.exec()
of that command return on completion (Process.exitValue())?
It might return a code that indicates failure.
When I run this code in the command prompt and the computer cannot be
found on the network it comes up with a message saying that the
network path wasn't found. How can I read in the error message that
the command prompt provides from within my JAVA Application.
Is that a question?
Andrew T.
| From: Roedy Green |
Date: Thursday, October 25, 2007
|
On Wed, 24 Oct 2007 14:48:32 -0700, christopher_board@xxxxxxxxxxx
wrote in message, quoted or indirectly quoted someone who said :
I am using shutdown -m \\computer name -r -f -t 30.
Experiment from the command
line until you get the commands right.
There is no
point in adding the confusion of JAVA up front.
Then emit them with exec. See
http://mindprod.com/jgloss/exec.html
It'll show you how to capture the response.
--
Roedy
Green Canadian Mind Products
The JAVA Glossary
http://mindprod.com
| From: Nigel Wade |
Date: Thursday, October 25, 2007
|
wrote in message:
Hi all.
I am currently trying to develop a JAVA applicatio that will enable me
to shutdown or restart computers remotely. I am doing this by using
the command prompt code in order to perform the shutdown. For example
I am using shutdown -m \\computer name -r -f -t 30.
When I run this code in the command prompt and the computer cannot be
found on the network it comes up with a message saying that the
network path wasn't found. How can I read in the error message that
the command prompt provides from within my JAVA Application.
Does
Windows cmd.exe
support command
pipe s? If it does you can run one command
and pipe the
output of that into another executable's
standard input. The
second
application just reads the
data on its standard input.
Any help in this matter'd be highly appreciated.
Try
piping (if cmd.exe supports) command output to a JAVA application and see
what it reads.
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@xxxxxxxxxxx
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
| From: Andrew Thompson |
Date: Thursday, October 25, 2007
|
wrote in message:
..
Does Windows cmd.exe support command pipes?
Sure does. But I haven't found a way to redirect the
System.err, just System.out.
[eg]
D:\projects>JAVA TestFileName
D:\projects\123.txt
Invalid
argument '12?3.txt'
D:\projects\12[3.txt
D:\projects\12{3.txt
D:\projects\12!3.txt
D:\projects\12\3.txt
D:\projects>JAVA TestFileName 1>op.txt
Invalid argument '12?3.txt'
D:\projects>pause
Press any
key to continue . . .
[/eg]
Having said that, I am not sure where the '1' in
the second invocation originates from, here is
the .bat
file used.
[.bat]
JAVA TestFileName
JAVA TestFileName > op.txt
pause
[/.bat]
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via
http://www.JAVAkb.com
| From: rossum |
Date: Thursday, October 25, 2007
|
On Thu, 25 Oct 2007 10:06:56 GMT, "Andrew Thompson"
<u32984@xxxxxxxxxxx>
wrote in message:
wrote in message:
..
Does Windows cmd.exe support command pipes?
Sure does. But I haven't found a way to redirect the
System.err, just System.out.
[eg]
D:\projects>JAVA TestFileName
D:\projects\123.txt
Invalid argument '12?3.txt'
D:\projects\12[3.txt
D:\projects\12{3.txt
D:\projects\12!3.txt
D:\projects\12\3.txt
D:\projects>JAVA TestFileName 1>op.txt
Invalid argument '12?3.txt'
D:\projects>pause
Press any key to continue . . .
[/eg]
Having said that, I am not sure where the '1' in
the second invocation originates from, here is
the .bat file used.
[.bat]
JAVA TestFileName
JAVA TestFileName > op.txt
pause
[/.bat]
Dimly recalling my
DOS days, try variations on:
>
1>
2>
>&
1>&
2>&
to see if
stderr gets redirected.
IIRC the & was required, I am not
sure about the 1 and 2. I have no idea if this still works under
Windows
emulation of DOS.
rossum
| From: Lew |
Date: Thursday, October 25, 2007
|
wrote in message:
>
stdout
1>
stdout
2>
stderr
>&
stderr redirected to stdout's output
1>&
stdout redirected to stdout's output - does not make sense
2>&
stderr redirected to stdout's output
to see if stderr gets redirected. IIRC the & was required, I am not
sure about the 1 and 2. I have no idea if this still works under
Windows emulation of DOS.
If not, use cygwin which brings a UNIX-like command shell and associated
utilities to Windows.
from "man bash":
Moving File Descriptors
The redirection operator
[n]<&digit -
moves the file descriptor digit to file descriptor n, or the standard input (file descriptor 0) if n isn't specified. digit is closed after being duplicated to n.
Similarly, the redirection operator
[n]>&digit-
moves the file descriptor digit to file descriptor n, or the standard output (file descriptor 1) if n isn't specified.
--
Lew
| From: Roedy Green |
Date: Thursday, October 25, 2007
|
On Thu, 25 Oct 2007 10:06:56 GMT, "Andrew Thompson"
<u32984@xxxxxxxxxxx>
wrote in message, quoted or indirectly quoted someone who said :
Sure does. But I haven't found a way to redirect the
System.err, just System.out.
try 1> and 2>
--
Roedy Green Canadian Mind Products
The JAVA Glossary
http://mindprod.com
| From: Andrew Thompson |
Date: Thursday, October 25, 2007
|
| From: Roedy Green |
Date: Saturday, October 27, 2007
|
On Fri, 26 Oct 2007 02:18:18 GMT, "Andrew Thompson"
<u32984@xxxxxxxxxxx>
wrote in message, quoted or indirectly quoted someone who said :
Thanks, to you and and to all who clarified the redirect symbols
on Windows. What you are saying explains the 'mysterious'
appearance of the '1' in my initial output.
see
http://mindprod.com/jgloss/fournt.html
If you are going to do anything fancy with bat files in Windows. It is
a replacement command
process or with various extensions that makes it
workable, but not beautiful.
--
Roedy Green Canadian Mind Products
The JAVA Glossary
http://mindprod.com
Next Message: JVM error (from JDeveloper)
Blogs related to Get error message from Command prompt
i have a registration usb disk drive that I have formatted as ext2 ...
I
get an
error message when I try to run the script, even though I’m using the sudo
command. driver level “lshw”, is it mounted “mount” at least. “the script”? also,you shouldn’t see any errors when you plug it in and do “dmesg”
...
Hi Ive made java 6 a custom x86_64 R rpm package wo X deps Even ...
all lvm
command fail.. all pv commands fail pvdisplay fales. but when I boot from the rescue cd everything is there. What is the exact
error message? system starts to boot then halts party way while loading lvm i’m just rebooting now.
...
hi debian folks java i have debian sarge on a vserver and syslog ...
im gonna try and hook my lan to that nic that is giveing that output
message and see if it does work at least brb. for starters … not in etch. abrotman what is? audacious. hello, why when a execute gedit in terminal i
get this
error ...
everyone java I just got my dell laptop installed ubuntu but there ...
Error messages? Smoke? jack,is it necessary to install graphic driver to enable desktop effects?? i. Not a good question… Apples and oranges… are you comparing a specific programs performance.. not a windows program under wine or
...
so I have java 6 4 hard drives I originally thought I would have ...
I’m getting a problem
message with the
command you gave me to revert back … it’s saying ln: creating symbolic link `/usr/local/bin/rhythmbox’ to `/usr/bin/rhythmbox’: File exists. be careful with a shrink, it may not work the way you
...
java.io.FileNotFoundException: /home/alexh/.aws/auth
I'ma newbie ... am having trouble using the
command line tools ... everything works fine in the sandbox, when I move to production mode I
get the following
error: ==>Cannot find the declaration of element 'ExternalQuestion'
...