Re: os.system questions
- From: "Eric Price" <soyouthinkimgonnalikethis@xxxxxxxxxxx>
- Date: Sat, 31 Mar 2007 09:38:53 -0400
Oops! The problem isn't in the os.system call. It's in the fact that I don't call the function. That is, I write a script called "test.py" with a function in it called "freshReboot". Now, how do I call that function from test.py? That is, how do I write a cron event such that "freshReboot" actually gets called when I run test.py?
TIA,
Eric
From: "Eric Price" <soyouthinkimgonnalikethis@xxxxxxxxxxx>
To: khemkaamit@xxxxxxxxx
CC: python-list@xxxxxxxxxx
Subject: Re: os.system questions
Date: Sat, 31 Mar 2007 09:33:03 -0400
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
--
http://mail.python.org/mailman/listinfo/python-list
_________________________________________________________________
5.5%* 30 year fixed mortgage rate. Good credit refinance. Up to 5 free quotes - *Terms https://www2.nextag.com/goto.jsp?product=100000035&url=%2fst.jsp&tm=y&search=mortgage_text_links_88_h2a5d&s=4056&p=5117&disc=y&vers=910
.
- Prev by Date: Re: os.system questions
- Next by Date: Re: Sorting a multidimensional array by multiple keys
- Previous by thread: Re: os.system questions
- Next by thread: Re: os.system questions
- Index(es):
Relevant Pages
|