PHP executes shell scripting issues

Source: Internet
Author: User
The Xamp environment platform on Ubuntu. When using PHP's shell_exec to execute shell scripts, only partial commands can be executed, or only echo commands can be executed, such as cat, more, and so on, without any return information, such as:
echo "a"
Cat A.txt
More B.txt
echo "B"
The result is: AB, the Middle 2 command is not executed, there is no feedback information, why?


Reply to discussion (solution)

The local execution of the shell script is successful, but using PHP will not be able to execute the

Someone's not there, no one's not there.
Someone's not there.

Permissions issues.
chmod 0777 A.txt Look

$ ll A.txt
$ ll B.txt
Give it a try

The echo above you should not be the echo of the Linux command, it should be the echo of PHP.
$results = ' cat a.txt '; or $results = Shell_exec (' Cat a.txt ');
Echo $results try it.

The problem is done.
1. Path problem, determine the working directory
2. Permissions issues, the relationship between daemon and users should be clear.
Hope to let everyone learn from

a.sh

#!/bin/sh

echo ' Hello World ' >1.txt
/usr/bin/unoconv-f Pdf/mnt/www/test/test.txt

index.php

EXEC ("/usr/bin/a.sh", $status);


Why not generate PDF files.

  • 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.