Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

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

share|improve this answer
add comment

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

share|improve this answer
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.