Python结构:如何在屏幕会话中执行命令
我正在做以下工作:Python结构:如何在屏幕会话中执行命令,python,fabric,devops,gnu-screen,Python,Fabric,Devops,Gnu Screen,我正在做以下工作: 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
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))
一旦屏幕打开,织物就会进入无限循环,永远不会出现。您是否尝试过执行
screen-Rd
:
-d -R Reattach a session and if necessary detach or even create it first.
您是否尝试过执行
screen-Rd
:
-d -R Reattach a session and if necessary detach or even create it first.