shell-exec

Limit execution time of shell_exec and grab whatever output is generated

我只是一个虾纸丫 提交于 2021-02-19 07:38:10
问题 I'm trying to limit the max execution time of shell_exec in PHP to say 20 seconds and fetch whatever output is generated during this time. If shell_exec finishes in less than 20 seconds the script should proceed directly. More specifically I'm developing a function that iterates through a large number of revisions of a subversion repository. For each revision it's fetching the svn diff and counts the number of lines added. The problem is that if very large files have been committed in a

Limit execution time of shell_exec and grab whatever output is generated

冷暖自知 提交于 2021-02-19 07:35:12
问题 I'm trying to limit the max execution time of shell_exec in PHP to say 20 seconds and fetch whatever output is generated during this time. If shell_exec finishes in less than 20 seconds the script should proceed directly. More specifically I'm developing a function that iterates through a large number of revisions of a subversion repository. For each revision it's fetching the svn diff and counts the number of lines added. The problem is that if very large files have been committed in a

PHP shell_exec is not responding on python command line

两盒软妹~` 提交于 2021-02-11 16:59:22
问题 Hi I am running shell_exec on my PHP Application, Here is the code, $path = "C:/scripts/"; chdir($path); $py_commonscript = 'python Common_Script.py'; $exec = shell_exec($py_commonscript); echo "<pre>$exec</pre>"; This code doesn't give any result and does not generate a file. When I tried running manually on the command line it is working and was able to generate a file. I tried to execute this one below and it was able to display some result. $sample = shell_exec('ls -lart'); echo "<pre>

shell_exec echo'ing too fast or too late

北城以北 提交于 2021-02-05 11:57:27
问题 So I read throug this article: https://trac.ffmpeg.org/wiki/PHP and found this: <?php echo "Starting ffmpeg...\n\n"; echo shell_exec("ffmpeg -i input.avi output.avi >/dev/null 2>/dev/null &"); echo "Done.\n"; the code works almost perfectly fine, but the only thing that bothers me is, that because the shell_exec is being executed in the background (so there is no loading sign on the tab the whole time) all the echo's are being executed immediatly. This means, that the "Done" echo is being

Composer.phar don't want to run by shell_exec from PHP script. Why?

女生的网名这么多〃 提交于 2020-08-19 12:28:46
问题 Trying to execute it with all possible params, such as -d and full path etc.. No errors. When running another commands, all is ok, when running composer from CMD, all is ok too. Have tried exec, system, shell_exec etc.. What it could be? echo system('php composer.phar install'); 回答1: Try outputting the error stream as well: system('php composer.phar install 2>&1'); It might give you more of a hint as to what is going wrong. 回答2: Try this $path = 'path where, composer.phar and composer.json

Composer.phar don't want to run by shell_exec from PHP script. Why?

三世轮回 提交于 2020-08-19 12:21:51
问题 Trying to execute it with all possible params, such as -d and full path etc.. No errors. When running another commands, all is ok, when running composer from CMD, all is ok too. Have tried exec, system, shell_exec etc.. What it could be? echo system('php composer.phar install'); 回答1: Try outputting the error stream as well: system('php composer.phar install 2>&1'); It might give you more of a hint as to what is going wrong. 回答2: Try this $path = 'path where, composer.phar and composer.json

Composer.phar don't want to run by shell_exec from PHP script. Why?

微笑、不失礼 提交于 2020-08-19 12:21:43
问题 Trying to execute it with all possible params, such as -d and full path etc.. No errors. When running another commands, all is ok, when running composer from CMD, all is ok too. Have tried exec, system, shell_exec etc.. What it could be? echo system('php composer.phar install'); 回答1: Try outputting the error stream as well: system('php composer.phar install 2>&1'); It might give you more of a hint as to what is going wrong. 回答2: Try this $path = 'path where, composer.phar and composer.json

PHP passing string with apostrophe to shell_exec

穿精又带淫゛_ 提交于 2020-06-08 19:59:18
问题 I’m trying to pass a string (drawn from a PDO query to an MYSQL DB) via PHP shell_exec to a *nix program, in this case xtide. All works fine until I pass a string containing an apostrophe. This works in the Terminal on OSX: house@New-MacBook-Pro:~$ tide -l "Nomans Land, Martha's Vineyard, Massachusetts" but the exact same string, from a PDO query to a MYSQL DB, and passed as a variable into shell_exec, always fails. It doesn’t seem to matter how I arrange the single/double quotes. Running

How to execute shell_exec on EC2 Linux

江枫思渺然 提交于 2020-02-02 15:34:07
问题 I am running an API on a EC2 Linux instance. I try to to execute a Python script from a PHP file. The path to the PHP file is /var/www/html/droptop/api/event/test.php . The path to the Python script is /var/www/html/droptop/blacklist/profanity.py . The Python script recieves two strings and checks whether one of these two strings contain objectionable content via Profanity Check . Then it returns 0 if no objectionable content was found, otherwise it returns 1 . However, shell_exec always

Bash script live output executed from PHP

梦想的初衷 提交于 2020-01-11 11:55:30
问题 I'm trying to execute a bash script from php and getting its output in real time. I am applying the answers found here: However they are not working for me. When I invoke the .sh script on this way, it works fine: <?php $output = shell_exec("./test.sh"); echo "<pre>$output</pre>"; ?> However, when doing: <?php echo '<pre>'; passthru(./test.sh); echo '</pre>'; ?> or: <?php while (@ ob_end_flush()); // end all output buffers if any $proc = popen(./test.sh, 'r'); echo '<pre>'; while (!feof($proc