hexacyanide
hexacyanide

Reputation: 91799

Bash: Screen parameters being interpreted incorrectly

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?

Upvotes: 0

Views: 140

Answers (1)

John Kugelman
John Kugelman

Reputation: 362147

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'

Upvotes: 2

Related Questions