os.system questions
Eric Price
soyouthinkimgonnalikethis at hotmail.com
Sat Mar 31 09:33:03 EDT 2007
Great! That seems to work fine:
#!/usr/local/bin/python
import re, os
def freshReboot():
up = os.popen('uptime').readlines()
up = up[0]
if re.search('day|hour', up):
pass
else:
tup = re.split('min', up)
first = tup[0]
n = len(first)
char = first[n-3:n-2]
if re.match(' ', char):
os.system("/usr/local/etc/rc.d/zz_mysql_starter_script.sh")
However, I don't see evidence that the os.system call at the end actually
executes said script. The reason for this screwy script is because MySQL
doesn't set the proper environment on boot and that screws up my Zope
instances. So, I'll cron this script to run every 6 mins. If the server has
been up less than 10 mins, this script will run. So, I rebooted the server
and ran the script. But it didn't execute the os.system script at the end!
If I run this from the python prompt instead:
import re, os
def a():
up = os.popen('uptime').readlines()
up = up[0]
up = " 7:25AM up 2 mins, 1 user, load averages: 2.42, 1.01, 0.41"
if re.search('day|hour', up):
pass
else:
tup = re.split('min', up)
first = tup[0]
n = len(first)
char = first[n-3:n-2]
if re.match(' ', char):
print "gotcha!"
it prints "gocha!" Now, that substitution for the "up" var is what I got as
output from the "uptime" command at the shell prompt. So, obviously, it
should be running the script! What am I doing wrong?
TIA,
Eric
_________________________________________________________________
Watch free concerts with Pink, Rod Stewart, Oasis and more. Visit MSN
Presents today.
http://music.msn.com/presents?icid=ncmsnpresentstagline&ocid=T002MSN03A07001
More information about the Python-list
mailing list