2

I'm using screen (LINUX) to run servers or task, but I want to put more than one task in one screen, is it impossible? Like:

screen -A -m -d -S test_screen userdel -r user_test && useradd -m -p 'encrypt_pass' user_test

How to change && because it leads first task left in screen and another execute in display and "" doesn't help, too.

I want to do it that each task executes one after the other.

mailq
  • 17,023
  • 2
  • 37
  • 69
altdovydas
  • 33
  • 3

3 Answers3

1

Try this screen -A -m -d -S test_screen sh -c "userdel -r user_test && useradd -m -p 'encrypt_pass' user_test"

Encasing the command in sh -c "" runs the whole command in the default shell

Rwky
  • 774
  • 1
  • 8
  • 17
0

Put all commands you want to execute into a shell script and run it with screen.

quanta
  • 51,413
  • 19
  • 159
  • 217
0

Several ideas:

  1. Put the commands in a script, run the script from within the screen.
  2. Use subshell (i.e. put the commands inside ( ) )
  3. Use bash -c 'command a && command b' as the command to be run by screen
Paweł Brodacki
  • 6,511
  • 20
  • 23