How to start a program with bash -c, redirect / disable GUI of that app
up vote
0
down vote
favorite
Currently I'm starting a java application with
bash -c java -jar app.jar -config config.json
The app opens a window, displaying some output and closes. The output is also available on stdout, so I don't need (want) the GUI to display.
How can I prevent bash to forward the X output?
Follow up:
I'm running this in a go application, so based on el.pescado's answer, I have implemented this as:
func runcmd(cmd string, workdir string) (byte, error) {
ex := exec.Command("bash", "-c", cmd)
ex.Env = string{"DISPLAY= "}
ex.Dir = workdir
return ex.Output()
}
bash go
add a comment |
up vote
0
down vote
favorite
Currently I'm starting a java application with
bash -c java -jar app.jar -config config.json
The app opens a window, displaying some output and closes. The output is also available on stdout, so I don't need (want) the GUI to display.
How can I prevent bash to forward the X output?
Follow up:
I'm running this in a go application, so based on el.pescado's answer, I have implemented this as:
func runcmd(cmd string, workdir string) (byte, error) {
ex := exec.Command("bash", "-c", cmd)
ex.Env = string{"DISPLAY= "}
ex.Dir = workdir
return ex.Output()
}
bash go
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Currently I'm starting a java application with
bash -c java -jar app.jar -config config.json
The app opens a window, displaying some output and closes. The output is also available on stdout, so I don't need (want) the GUI to display.
How can I prevent bash to forward the X output?
Follow up:
I'm running this in a go application, so based on el.pescado's answer, I have implemented this as:
func runcmd(cmd string, workdir string) (byte, error) {
ex := exec.Command("bash", "-c", cmd)
ex.Env = string{"DISPLAY= "}
ex.Dir = workdir
return ex.Output()
}
bash go
Currently I'm starting a java application with
bash -c java -jar app.jar -config config.json
The app opens a window, displaying some output and closes. The output is also available on stdout, so I don't need (want) the GUI to display.
How can I prevent bash to forward the X output?
Follow up:
I'm running this in a go application, so based on el.pescado's answer, I have implemented this as:
func runcmd(cmd string, workdir string) (byte, error) {
ex := exec.Command("bash", "-c", cmd)
ex.Env = string{"DISPLAY= "}
ex.Dir = workdir
return ex.Output()
}
bash go
bash go
edited yesterday
asked yesterday
G-M
961111
961111
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You have several options:
- First, you should check if that application can run without GUI (often called "headless" mode)
- You can unset
DISPLAY
variable, so that your app won't find your X11 server - but keep in mind that application might not work without X server
eg.
DISPLAY= bash -c java -jar app.jar -config config.json # note space after '='
# or
env -u DISPLAY bash -c java -jar app.jar -config config.json
- You could use in-memory virtual X server such as xfvb and point your application to display its windows there.
eg.
Xvfb :1 -screen 0 1600x1200x32
DISPLAY=:1 bash -c java -jar app.jar -config config.json
Thanks, works like a charm!
– G-M
yesterday
@G-M Which solution works for you ?
– mgagnon
yesterday
@mgagnon #2DISPLAY= bash -c java -jar app.jar -config config.json
– G-M
yesterday
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You have several options:
- First, you should check if that application can run without GUI (often called "headless" mode)
- You can unset
DISPLAY
variable, so that your app won't find your X11 server - but keep in mind that application might not work without X server
eg.
DISPLAY= bash -c java -jar app.jar -config config.json # note space after '='
# or
env -u DISPLAY bash -c java -jar app.jar -config config.json
- You could use in-memory virtual X server such as xfvb and point your application to display its windows there.
eg.
Xvfb :1 -screen 0 1600x1200x32
DISPLAY=:1 bash -c java -jar app.jar -config config.json
Thanks, works like a charm!
– G-M
yesterday
@G-M Which solution works for you ?
– mgagnon
yesterday
@mgagnon #2DISPLAY= bash -c java -jar app.jar -config config.json
– G-M
yesterday
add a comment |
up vote
2
down vote
accepted
You have several options:
- First, you should check if that application can run without GUI (often called "headless" mode)
- You can unset
DISPLAY
variable, so that your app won't find your X11 server - but keep in mind that application might not work without X server
eg.
DISPLAY= bash -c java -jar app.jar -config config.json # note space after '='
# or
env -u DISPLAY bash -c java -jar app.jar -config config.json
- You could use in-memory virtual X server such as xfvb and point your application to display its windows there.
eg.
Xvfb :1 -screen 0 1600x1200x32
DISPLAY=:1 bash -c java -jar app.jar -config config.json
Thanks, works like a charm!
– G-M
yesterday
@G-M Which solution works for you ?
– mgagnon
yesterday
@mgagnon #2DISPLAY= bash -c java -jar app.jar -config config.json
– G-M
yesterday
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You have several options:
- First, you should check if that application can run without GUI (often called "headless" mode)
- You can unset
DISPLAY
variable, so that your app won't find your X11 server - but keep in mind that application might not work without X server
eg.
DISPLAY= bash -c java -jar app.jar -config config.json # note space after '='
# or
env -u DISPLAY bash -c java -jar app.jar -config config.json
- You could use in-memory virtual X server such as xfvb and point your application to display its windows there.
eg.
Xvfb :1 -screen 0 1600x1200x32
DISPLAY=:1 bash -c java -jar app.jar -config config.json
You have several options:
- First, you should check if that application can run without GUI (often called "headless" mode)
- You can unset
DISPLAY
variable, so that your app won't find your X11 server - but keep in mind that application might not work without X server
eg.
DISPLAY= bash -c java -jar app.jar -config config.json # note space after '='
# or
env -u DISPLAY bash -c java -jar app.jar -config config.json
- You could use in-memory virtual X server such as xfvb and point your application to display its windows there.
eg.
Xvfb :1 -screen 0 1600x1200x32
DISPLAY=:1 bash -c java -jar app.jar -config config.json
answered yesterday
el.pescado
15.7k22771
15.7k22771
Thanks, works like a charm!
– G-M
yesterday
@G-M Which solution works for you ?
– mgagnon
yesterday
@mgagnon #2DISPLAY= bash -c java -jar app.jar -config config.json
– G-M
yesterday
add a comment |
Thanks, works like a charm!
– G-M
yesterday
@G-M Which solution works for you ?
– mgagnon
yesterday
@mgagnon #2DISPLAY= bash -c java -jar app.jar -config config.json
– G-M
yesterday
Thanks, works like a charm!
– G-M
yesterday
Thanks, works like a charm!
– G-M
yesterday
@G-M Which solution works for you ?
– mgagnon
yesterday
@G-M Which solution works for you ?
– mgagnon
yesterday
@mgagnon #2
DISPLAY= bash -c java -jar app.jar -config config.json
– G-M
yesterday
@mgagnon #2
DISPLAY= bash -c java -jar app.jar -config config.json
– G-M
yesterday
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409114%2fhow-to-start-a-program-with-bash-c-redirect-disable-gui-of-that-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown