Python, how to tell if screen is running.
Posted
by Joe Spoon
on Stack Overflow
See other posts from Stack Overflow
or by Joe Spoon
Published on 2010-04-30T15:35:34Z
Indexed on
2010/04/30
15:37 UTC
Read the original article
Hit count: 275
Hello, I am very new to programming and am trying to run a python code to see if the screen program is running and if it is then to not run the rest of the code. This is what I have and it's not working.
!/usr/bin/python
import os var1 = os.system ('screen -r > /root/screenlog/screen.log') fd = open("/root/screenlog/screen.log") content = fd.readline()
while content: if content == "There is no screen to be resumed.": os.system ('/etc/init.d/tunnel.sh') print "The tunnel is now active." else: print "The tunnel is running." fd.close()
I know there are probably several things here that don't need to be and quite a few that I'm missing. I will be running this program in cron. Thanks for any help.
© Stack Overflow or respective owner