FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
zstack/utils/src/main/java/org/zstack/utils/Linux.java at master · zstackio/zstack · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
zstackio
/
zstack
Public
Notifications
You must be signed in to change notification settings
Fork
399
Star
1.4k
Code
Issues
163
Pull requests
13
Actions
Projects
Wiki
Security and quality
4
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
zstack
/
utils
/
src
/
main
/
java
/
org
/
zstack
/
utils
/
Linux.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
68 lines (57 loc) · 1.73 KB
Breadcrumbs
zstack
/
utils
/
src
/
main
/
java
/
org
/
zstack
/
utils
/
Linux.java
Copy path
File metadata and controls
executable file
·
68 lines (57 loc) · 1.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package
org
.
zstack
.
utils
;
import
org
.
apache
.
commons
.
io
.
IOUtils
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
Collections
;
import
java
.
util
.
List
;
/**
* Created with IntelliJ IDEA.
* User: frank
* Time: 11:50 PM
* To change this template use File | Settings | File Templates.
*/
public
class
Linux
{
public
static
class
ShellResult
{
private
String
stderr
;
private
String
stdout
;
private
int
exitCode
;
public
String
getStderr
() {
return
stderr
;
}
public
void
setStderr
(
String
stderr
) {
this
.
stderr
=
stderr
;
}
public
String
getStdout
() {
return
stdout
;
}
public
void
setStdout
(
String
stdout
) {
this
.
stdout
=
stdout
;
}
public
int
getExitCode
() {
return
exitCode
;
}
public
void
setExitCode
(
int
exitCode
) {
this
.
exitCode
=
exitCode
;
}
}
public
static
ShellResult
shell
(
String
cmdStr
) {
String
[]
cmds
=
cmdStr
.
split
(
" "
);
List
<
String
>
cmdLst
=
new
ArrayList
<
String
>();
Collections
.
addAll
(
cmdLst
,
cmds
);
return
shell
(
cmdLst
);
}
public
static
ShellResult
shell
(
List
<
String
>
cmd
) {
try
{
ProcessBuilder
pb
=
new
ProcessBuilder
(
cmd
);
Process
pro
=
pb
.
start
();
int
exitCode
=
pro
.
waitFor
();
ShellResult
ret
=
new
ShellResult
();
ret
.
setExitCode
(
exitCode
);
ret
.
setStderr
(
IOUtils
.
toString
(
pro
.
getErrorStream
()));
ret
.
setStdout
(
IOUtils
.
toString
(
pro
.
getInputStream
()));
return
ret
;
}
catch
(
Exception
e
) {
Thread
.
currentThread
().
interrupt
();
throw
new
RuntimeException
(
e
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL