Oscar, seems you may be correct.  I need to run this program as a superuser.  
However, after some more tests with simple commands...  I seem to be working 
correctly from any permission level in python.... Except for the output write 
command from the database to a file.  Which runs fine if I paste it into the 
cmd line.  Also, subprocess.call_check() returns clean.  However, nothing is 
written to the output file when called from python.

so this cmd runs great from the cmd line (sudo or no) however the output file 
in this case is owned by the sysadmin either way... not root?

/usr/local/Calpont/mysql/bin/mysql 
--defaults-file=/usr/local/Calpont/mysql/my.cnf -u root myDB < 
/home/myusr/jobs/APP_JOBS/JOB_XXX.SQL > /home/myusr/jobs/APP_JOBS/JOB_XXX.TXT


When run from sudo python (other files are also created and owned by root 
correctly)  however no output is written from the db command zero byte file 
only (owned by root)... returns to python with no errors.

I'm sorta at a loss.  I'd rather still avoid having python connect to the db 
directly or reading the data from stdout, is a waste or mem and time for what I 
need.

Thanks for any more thoughts.

> 
> Because of the root permissions on the file? What happens if you write
> 
> to a file that doesn't need privileged access?
> 
> 
> 
> Instead of running the "exact command", run the cat commands you
> 
> posted (that Steven has confirmed as working) and run them somewhere
> 
> in your user directory without root permissions.
> 
> 
> 
> Also you may want to use subprocess.check_call as this raises a Python
> 
> error if the command returns an error code.
> 
> 
> 
> 
> 
> Oscar

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to