HOW to use using fabric with dtach, screen, is there any example

I have a lot of googled and the faq stuff also mentions using the dtach screen with it, but didn't find how to implement it? below is my wrong code, sh will not be executed, since it is excluded this is a nohup task

def dispatch(): run("cd /export/workspace/build/ && if [ -f spider-fetcher.zip ];then mv spider-fetcher.zip spider-fetcher.zip.bak;fi") put("/root/build/spider-fetcher.zip","/export/workspace/build/") run("cd /export/script/ && sh ./restartCrawl.sh && echo 'finished'") 
+7
source share
2 answers

I managed to do this in two stages:

  • Start the tmux session on the remote server in a separate mode:

    run ("tmux new -d -s foo")

  • Send the command to the tmux disconnected session:

    run ("tmux send -t foo.0 ls ENTER")

here '-t' defines the target session ('foo') and 'foo.0' reports the number of the panel in which the ls command should be executed.

+5
source

you can simply add a screen to the command you want to run: run ("long screen command")

The tissue, although it does not save state, is like something like an expectation, since each run / sudo / etc is their own sperm command, not knowing the state of the last command. For example, run ("cd / var"), run ("pwd") will not print / var, but the home directory of the user who entered the field.

+2
source

All Articles