Re: os.system questions



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

.



Relevant Pages

  • Re: Getting original working directory
    ... Also I do not agree that such thing is not possible because after python script finishes its work, it naturally gets back into the original location from where you started the script. ... Ensure your application has the right permissions to access the web service. ... "A GUID to to identify this rememberer" ... def get_proxy ...
    (comp.lang.python)
  • Re: How do I access a main frunction from an import module?
    ... def a: ... may/must call 0, 1, or many because blah blah blah ..." ... have Python ... script separate from each other, being that python is so flexible. ...
    (comp.lang.python)
  • Re: Problem with popen on windows
    ... I just found a fix that works for me.. ... parent for the child script.. ... Private Function ParseCmdLine ... >> def system ...
    (comp.lang.ruby)
  • Re: Problem getting user input
    ... After the prompt is printed, the script waits for the user to enter ... 11 def initialize ... puts "Enter string to change: ...
    (comp.lang.ruby)
  • Re: Ruby script to Module/Class refactor
    ... OOP idiom. ... data, such as its name, location, and other generic info. ... def validate_directories ... Does the script end up as a ruby ...
    (comp.lang.ruby)