2

I am trying to create a new screen so that the screen is detached at first, and its current folder is cd /home.

When I execute screen -dm "cd /home" (the parameter -dm means "Start screen in detached mode. This creates a new session but doesn't attach to it".) I get the error message:

Cannot identify account 'cd '.`

However, when I execute screen -dm "$(cd /home)", there is no error message, but the current folder in the created screen isn't /home.

Why?

3

The latter

screen -dm "$(cd /home)"

is substituted by the shell to get the message from CDPATH which shows which directory was reached by the cd command. But the cd command only applies to the subshell, and not the command-line that screen sees.

The former is not substituted, and screen does not know what to do with a directory named "cd /home"

Perhaps you meant something like this (no quotes):

    screen -dm cd /home

which fits into the pattern listed in the manual page:

screen [ -options ] [ cmd [ args ] ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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