0

I'm trying to start daemon screens with screen -dmS nameofscreen command. This works by itself, but when I use a command with && or | it seems to interpret it wrong.

Example: screen -dmS screen1 echo test && ls -al

It seems to be interpreted as (screen -dmS screen1 echo test) && (ls -al) and I'm looking for it to be interpreted as screen -dmS screen1 (echo test && ls -al).

How is this done? If I use () around the commands to be passed, screen doesn't accept it?

hexacyanide
  • 88,222
  • 31
  • 159
  • 162

1 Answers1

2

Parentheses and && and || are interpreted by the shell, not by screen. To get those operators to work in screen you need an explicit sub-shell.

screen -dmS screen1 sh -c 'echo test && ls -al'
John Kugelman
  • 349,597
  • 67
  • 533
  • 578