Volatil3
Volatil3

Reputation: 14998

Python Fabric: How to execute command in screen session

I am doing following:

with settings(host_string=h['server'].rstrip('\n').strip(), warn_only=True):
                # run("hostname -f")
                with cd('path/folder'):
                  # Check for Screen session, if none, create one otherwise screen -d -r
                    result = run('screen -r')
                    output_stdout = result.stdout.strip()
                    print('OUTPUT = ' + output_stdout)
                    if 'There is a screen on' in output_stdout:
                        run('screen -d -r')
                        run('exit')
                    elif 'There is no screen to be resumed' in output_stdout:
                        run('screen')
                        # Checking screen stats
                        run('screen -r')
                       # Generate Link File
                       run('python3 file.py ' + str(start) + ' ' + str(end))

What's been happening that once screen is on, fabric gets into an infinite loop and never comes out.

Upvotes: 0

Views: 851

Answers (1)

user1529891
user1529891

Reputation:

Have you tried doing screen -Rd:

-d -R   Reattach a session and if necessary detach or even create it first.

Upvotes: 2

Related Questions