Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 745 Vote(s) - 3.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting response of command line in Java

#1
I don't know if it is possible, but I want to see the response of my .bat file in Java.

Or a boolean of something that I can see that everything were going well! And if there where some errors that I can see the errors in Java.

Thanks
Reply

#2
Take a look at these code samples for executing shell commands through java: [Execute an external program](

[To see links please register here]

)

The code examples above do not utilize `ProcessBuilder` and therefore are not limited to Java 1.5 and above
Reply

#3
You need to run it using the [`ProcessBuilder`][1] (as long as you are running java 1.5 or above, if not check Alex's answer)

If you execute:

Process process = new ProcessBuilder("mybat.bat").command();

With the [`Process`][2] you can call

InputStream errorStream = process.getErrorStream();

You will capture the output from the bat to stderr.

You can also use [`getOutputStream()`][3] on process to get sdtout or check the return code with [`exitCode()`][4].


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

[4]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through