How to create a screen executing given command?

前端 未结 7 1587
星月不相逢
星月不相逢 2020-12-07 18:07

i\'m fairly new in *nix. Is there a way to create a screen, which will immediately execute a given command sequence (with their own arguments)? Two hours of googling yields

7条回答
  •  一整个雨季
    2020-12-07 18:25

    I think that you can use this

    function exec_in_screen() {
      name=$1
      command=$2
      screen -dmS $name sh; screen -S $name -X stuff "$command\n";
    } 
    

    Then...

    exec_in_screen "test" "ls"

提交回复
热议问题