https://github.com/darshanparajuli/jshellsession
A simple Java library for running shell commands.
https://github.com/darshanparajuli/jshellsession
command java java7 java8 jshellsession runner shell shell-command
Last synced: 10 months ago
JSON representation
A simple Java library for running shell commands.
- Host: GitHub
- URL: https://github.com/darshanparajuli/jshellsession
- Owner: darshanparajuli
- License: mit
- Created: 2017-04-11T05:21:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-13T01:05:47.000Z (about 5 years ago)
- Last Synced: 2025-01-13T23:32:18.109Z (12 months ago)
- Topics: command, java, java7, java8, jshellsession, runner, shell, shell-command
- Language: Java
- Homepage:
- Size: 61.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://travis-ci.org/darshanparajuli/JShellSession)
# JShellSession
A simple Java library for running shell commands.
## Simple example
```java
// create new JShellSession object
// Config.defaultConfig().builder() can be used to customize the default Config object
try (final JShellSession session = new JShellSession(Config.defaultConfig())) {
// run command, i.e "echo hello world"
final CommandResult result = session.run("echo hello world");
// check if command ran successfully
if (result.exitSuccess()) {
// process stdout or stderr (using result.stdErr())
for (String s : result.stdOut()) {
System.out.println(s);
}
} else {
System.err.println("Exit code: " + result.exitCode());
}
} catch (IOException e) {
e.printStackTrace();
}
```
###### Any feedback is much appreciated.
:sunglasses: