Frank
Frank

Reputation: 91

How to use xterm to launch screen with arguments

I'm currently using mobaxterm to launch xterms to connect to a remote server. I use...

xterm screen

I use screen because the connection is unreliable so screen allows me to recover sessions.

What I really want is to call "screen -RR" to reconnect sessions if there, or start a new one, but xterm doesn't allow command line arguments.

I've played around with -e, -ls, -hold, etc but I can't get it to work.

Any ideas?

[Edit] Additional information...

I've tried...

xterm ./script.sh

with screen -RR in it, but that runs, then exits. -l or -hold doesn't help.

xterm -e /bin/bash -c screen -RR

same problem, exits without giving me a prompt.

My current hack is... xterm ./mybash

where mybash a sym-link to /bin/bash, and I have a check in .bashrc looking for XTERM_SHELL = mybash, then launching screen -RR, but that runs 2 bash shells, so I have to exit twice to close the window.

Upvotes: 1

Views: 810

Answers (1)

Keith Thompson
Keith Thompson

Reputation: 263497

xterm -e should work. It takes one or more arguments specifying a command (plus its arguments) to execute under xterm (so it must be the last option).

For example, this should work

xterm -e screen -RR

There's no need to invoke /bin/bash to invoke screen.

Upvotes: 2

Related Questions