Suggestions on python method needed in php
Moderator: General Moderators
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
Suggestions on python method needed in php
Hi,
I have a php page which displays the entries stored in a logging database for applications that are being backed up on a server.
One thing that I am aiming to have on the php page is for it to display which process will be run next on the server.
These processes are called by the windows task scheduler.
I have written a python class which has a method for retrieving the next process that will run, out of the task scheduler.
At the moment, this method can simply return this process name / write it to a file / store it in a database.
My initial idea was to call the method every x minutes so that it updates the text file / database with the process name - which is then read by my php code - this seems a little intense.
It would make more sense for the python class to be called from my php script 'on demand', and for the returned value to be passed to the php script.
Can this be done and safely?
Thanks for any help in advance.
Here is a little diagram to help visualize what I am proposing:
Old method:
python > text file or database > php
New method
php > calls python
python > returns to php
I have a php page which displays the entries stored in a logging database for applications that are being backed up on a server.
One thing that I am aiming to have on the php page is for it to display which process will be run next on the server.
These processes are called by the windows task scheduler.
I have written a python class which has a method for retrieving the next process that will run, out of the task scheduler.
At the moment, this method can simply return this process name / write it to a file / store it in a database.
My initial idea was to call the method every x minutes so that it updates the text file / database with the process name - which is then read by my php code - this seems a little intense.
It would make more sense for the python class to be called from my php script 'on demand', and for the returned value to be passed to the php script.
Can this be done and safely?
Thanks for any help in advance.
Here is a little diagram to help visualize what I am proposing:
Old method:
python > text file or database > php
New method
php > calls python
python > returns to php
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
I am having one problem though, my python code returns the task name as a string, but when using this command, the returned value is just '0'.d11wtq wrote:Yes, I was going to suggest using shell command to acheive what you need. Seems reasonable to me.ianripping wrote:Ok, by googling, I have found this technique:
$command = "python_script.py"
system($command)
does this seem sustainable / acceptable?
Thanks
$command = "python_script.py"
system($command)
I think that the 0 represents the exit code from python, do you know how I can get the returned value?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Code: Select all
$command = "python_script.py"
$result = `$command`; //Backtick syntax to run command
echo $result;-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
With this I get a blank page.d11wtq wrote:Code: Select all
$command = "python_script.py" $result = `$command`; //Backtick syntax to run command echo $result;
You might be interested in http://netevil.org/node.php?nid=173&SC=1
Code: Select all
<?php
echo "<pre>\n";
foreach(win32_scheduler_enum_tasks() as $taskname) {
print_r(win32_scheduler_get_task_info($taskname));
}
echo "\n</pre>\n";
?>- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia