0

Can you use shared memory to communicate between php scripts and python program in windows,PHP is running as a web server module ?

i've used this in my php script : :

$shm_id = shmop_open($id, "c", 0644, strlen($data));
$shm_size = shmop_size($shm_id);
$shm_bytes_written = shmop_write($shm_id,$data, 0);
exec("c:/python27/python script.py",$output);
if(sizeof($output)){
   //operations....
}
shmop_delete($shm_id)
shmop_close($shm_id);

can i retrieve $data from in python ? any references ?

3
  • No, because you've deleted it. Commented Jan 17, 2012 at 4:35
  • He deleted it after executing the python script. Commented Jan 17, 2012 at 4:50
  • oops ! my bad but i have these lines commented out in my text editor ! so how i can do that on python ! thanks in advance ! Commented Jan 17, 2012 at 5:12

1 Answer 1

1

You can pass it as an argument to your python script using subprocess.call instead of exec it looks like this:

returnCode = subprocess.call(['path/script.py', arg1, arg2])

You can find the docs at: http://docs.python.org/library/subprocess.html

From python get the args with:

args[0] is the program name from the command line

args[1] is arg1

args[2] is arg2

etc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.