I have a shell script that executes some mySQL backups. I want to be able to run these backups from a browser, so I have a python script that calls the shell script using os.system(). The script works when run from the command line, but when run by visiting the URL from a browser, the shell script is not run.
#!/usr/bin/python
import os
os.system("/srv/www/server_utils/mysql_backup.sh")
print "Content-Type: text/html\n"
print "mySQL Backups completed."
(print "Content-Type: text/html\n" is there to prevent a 500 error from being displayed)
Most likely the backup script requires specific privileges to run (read permission on the DB, write permission on the backup directory, or both), and the web server does not have these privileges. The solution will depend on what operating system is running the server..