How to attach to existing screen session or create a new one and run a command?

StackOverflow https://stackoverflow.com/questions/21727559

  •  10-10-2022
  •  | 
  •  

سؤال

I'm using

screen -RdS SessionName

To attach to existing session if exist or create a new session and attach to it. I also have

screen -RdS SessionName -X stuff 'ls -l'`echo -ne '\015'`

To run a command in a screen session. However, I expect to be inside the screen session after this command. What is the command which does what the first does but also runs some command inside screen?

هل كانت مفيدة؟

المحلول

For now the following solution completely satisfies me

screen -S SessionName -X stuff 'ls -l'`echo -ne '\015'`; screen -RdS SessionName
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top