WSL run linux from windows without spawning a cmd-window

前端 未结 3 1215
礼貌的吻别
礼貌的吻别 2020-12-08 22:59

I have WSL bash running in a cmd. I don\'t use it for anything, it just hangs there to keep the WSL system alive.

When I start X applications:

bash -         


        
3条回答
  •  粉色の甜心
    2020-12-08 23:39

    So I just made this workaround for now. I really hope that there's a better way than this, but here it goes:

    In the command prompt that lives purely to keep WSL alive, I have this script running:

    wsl_run_server

    #!/bin/bash
    set -e
    nc -kl 127.0.0.1 15150 | sh
    

    And then I have this command to execute commands in background:

    wsl_run_command

    if ! pidof -x bin/wsl_run_server; then
        echo wsl_run_server isnt running!
        exit 1
    fi
    echo \($@\) \& | nc localhost 15150
    

    from windows I then call:

    bash -c "DISPLAY=:0 ~/bin/wsl_run_command xmessage hello"
    

提交回复
热议问题