1

I am currently setting up a server and there are different programs I want to run in the background, while still being able to look at the console of each program on demand.

So I'm trying to automatically create a screen for each program and start the program inside of the created screen, but the commands inside the screen dont seem to be running.

I am creating a screen with screen -dmS screen1 and trying to run a command with screen -S screen1 -X cmd, but the screen doesnt do anything.
For example, if I run screen -S screen1 -X touch /home/user/test, the file isnt created.

The autostart problem is resolved

1 Answer 1

1

You need to send an enter for that to work. To do so, press ctrl+v and then type Enter. For example, your command would look like this:

screen -S screen1 -X stuff 'touch /home/user/test^M'

Keep in mind that will just 'stuff' text into your first window, that will fail if there's already some 'text' in the console.

Take a look at GNU screen FAQ: How to send a command to a window in a running screen session from the commandline for additional examples.

One way to do so at screen startup is using .screenrc with something like:

# Start some screens by default
screen -t touch -L /bin/sh -c "touch ~/test3;bash"
screen -t mc -L /bin/sh -c "mc;bash"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .