PHP running Python script under IIS

Source: Internet
Author: User

A: Issues to be aware of

1.iis PHP has permission to Python.

2.cmd to owner permissions.

The encoding format in the 3.cmd command line is GBK.

4.exec (), Shell_exec (), System (), PassThru () differences.

5.windows version corresponding to the Python version, I here the company system is very old, encountered a lot of pits.

Two: examples

1. I use this example as an example of PassThru. is also the direct output result.

2. On the PHP source

Header ("Content-type:text/html;charset=utf-8");

Receive the form (here This params is just an example, mainly to let everyone know how to send a reference)
$params = $_post[' params '];
$str = Iconv ("Utf-8", "Gb2312//ignore", $car _card);

Call Python (the full directory is used here)
$common = "D:/python27/python.exe d:/compiled/pingan_data_launch.py $params";
$res = @passthru ("$common", $result);

3. On the Python source

# _*_ Coding:utf-8 _*_
For I in range (10):
A = ' My city '
Print (a)

It's 4.ok.

PHP running Python script under IIS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.