I am very new to PHP and writing a small web interface . Basically this has an image button and when I click it should install network printer.
My php code contains like this :
Code: Select all
<?php
$output = system('C:\Python27\python.exe c:\wamp\www\printer\scripts\pythoncode.py');
echo $output;
?>
My python code contains like this :
import subprocess
import os
psxmlgen = subprocess.Popen([r'C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe',
'-ExecutionPolicy',
'Unrestricted',
'c:\wamp\www\printer\scripts\printer.ps1',
], cwd=os.getcwd())
result = psxmlgen.wait()
When I click on the image button and it comes to my php page but nothing displays on the page nor it adds .
When I run the same code like this in command prompt : "C:\Python27\python.exe c:\wamp\www\printer\scripts\pythoncode.py" it adds the printer without any issues .
Any suggestions on how to execute python script in php ... Sample code if possible as I am struggling a lot to execute this for last 2 weeks and searching google doesn't help in fixing myself either its because i dont know how to execute in php nor understanding..
Thanks a lot in advance...