Execute Command with xterm and close

0

Im trying to execute a program with xterm and then close xterm with program running but it seems this doesn't work like I would expect it.

In bash there is the option bash -c [command] is there something in xterm too? Currently im using xterm -e [command] but this keeps the xterm window open till' my program has finished. But I want to open it, run the program, close it and keep the program running.

Why i want have a program startet through xterm when im not even using it? Im calling this through xpra on another computer but its not possible to only launch the program because i need it with the environment on the other pc.

Is there a way to do it?

Julian

Posted 2018-03-09T06:58:06.810

Reputation: 1

That looked good for the first try even if it seemed like it just got my open windown on the one machine to tho other and didnt open a new one. But now i cat get it to work anymore with nohup. What is the exact syntax? I tried xterm -e 'nohup sleep 5000 /path/to/program' But then i only try xterm -e '/path/to/program' it works again with the unwanted xterm window. – Julian – 2018-03-09T09:28:18.773

Answers

0

I don't think You need xpra. ssh is a good choice

ssh user@hostname /path/to/program

or ssh + screen

ssh user@hostname "screen /path/to/program"

or xpra + screen

xpra user@hostname "screen /path/to/program"

Tomasz Jakub Rup

Posted 2018-03-09T06:58:06.810

Reputation: 598

That doesnt help me unfortunately, im bound to xpra. – Julian – 2018-03-09T10:25:20.813

@Nico xpra+screen does not work? – Tomasz Jakub Rup – 2018-03-09T15:12:48.503

0

You seem to be confused about how things work. You don't need a terminal to run a program.

"Start xterm so you can start a process and then exit xterm" reduces to "start a process" and you can factor out xterm entirely.

I'm guessing you are looking for

nohup command >command.out 2>command.err &

which starts command as a background process (because of the &) with output going to command.out and error messages to command.err.

If you don't care about output or the signal handling with nohup, you might simply just want

command &

This doesn't allow you to interact with the background command (but neither does closing the xterm so I guess you don't need that); if you want to be able to do that, consider screen or tmux which lets you run the program in a virtual terminal you can disconnect from and reconnect to later.

tripleee

Posted 2018-03-09T06:58:06.810

Reputation: 2 480

Yes, i need the terminal. I'm connecting to another Pc via xpra and call a program but this program need to be run in a terminal – Julian – 2018-03-09T12:32:45.327

Then from where are you running xterm and why can't you run xpra from there? – tripleee – 2018-03-09T13:21:13.350

Im on a laptop in my network from there i run xpra onto another workstation in my network. On this workstation i run this program and view it via xpra on this laptop, but the program need to be started with xterm but i dont want to see this xterm window. – Julian – 2018-03-09T13:59:09.263

There are no programs which need to be started with xterm. I'm imagining you have been told you need to xpra somewhere xterm something to run something on somewhere but that's generally speaking not true. The answer you already received with ssh somewhere something & is correct and exhaustive, and if it doesn't work for you then your question lacks several crucial details. – tripleee – 2018-03-09T14:00:07.367

The program is selfwritten and it need to get started via xterm. My question is noch lacking crucial details you just wont accept that your answer doesn't help me. Im glad this forum exists an i got many good tips already but why are there some guys not accepting my requirements? – Julian – 2018-03-09T14:48:20.630

I want to start a a xterm via xpra and in this xterm i need to start a program and then i want xterm to be closed but the program needs to stay alive. – Julian – 2018-03-09T14:49:28.610

Maybe its ok to move this terminal where it doesn't show up. That should work too but i dont want to see it – Julian – 2018-03-09T14:51:00.470

You keep saying that, and I keep saying that cannot be exactly true. – tripleee – 2018-03-09T14:51:23.290

What is "not true"? That i have this requirement? I dont want solutions for a problem i dont have. I WANT to start a program with xpra through xterm and then make xterm "invisible" however... – Julian – 2018-03-09T14:54:45.760

You keep saying you are required to use xterm to start this program and I'm telling you that this does not make sense. Either the program requires a graphical user interface (which xterm does not provide, though if you are able to start xterm you will also be able to run other graphical clients) or it does not (in which case it doesn't matter which terminal or other console is used to launch the program, and so xterm isn't necessary either, and ssh or similar should suffice). – tripleee – 2018-03-09T23:12:08.917