Re: os.system questions



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

.



Relevant Pages

  • Re: Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script ... # have to place corresponding `LoadModule' lines at this location so the ...
    (perl.beginners)
  • Re: Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script Runs perfectly fine from the command prompt. ... # This is the main Apache HTTP server configuration file. ... LoadModule actions_module modules/mod_actions.so ...
    (perl.beginners)
  • Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script ... # have to place corresponding `LoadModule' lines at this location so the ...
    (perl.beginners)
  • Re: Regarding a selection for mobile code/scripting language
    ... Client Side scripting, so the server can send script commands to the client. ... I decided they should be scripted and mobile code. ...
    (Vuln-Dev)
  • Re: HTTPSConnection script fails, but only on some servers (long)
    ... (HTTP/CONNECT + switch to HTTPS) ... wget and my python script. ... >>The python script works with server A, ... the problem seems to depend on both the client ...
    (comp.lang.python)