Php executes shell scripts on the xamp environment platform on ubuntu. When using php shell_exec to execute shell scripts, only some commands can be executed, or only echo commands can be executed, such as cat and more, without any response information, such:
Echo ""
Cat a.txt
More B .txt
Echo "B"
The result is: AB. the two commands in the middle are not executed, and no feedback is provided. why?
Reply to discussion (solution)
The local shell script can be successfully executed, but php cannot be executed.
No, no, no
No
Permission issues.
Chmod 0777 a.txt
$ Ll a.txt
$ Ll B .txt
Try
The echo above 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
Problem solved
1. determine the working directory for path problems
2. for permission issues, the relationship between daemon and users should be clarified.
Hope you can learn from it
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 a PDF file.