shell-exec

all exec related PHP functions segfault

喜欢而已 提交于 2019-12-12 06:02:41
问题 I build PHP for android using the NDK. Most functions tested so far run perfectly, except... All exec related php function (like exec, shell_exec, popen, ..) all sefgault. php sample code (test.php) <?php $s=shell_exec("ls"); echo $s ?> result: # php test.php [1] Segmentation fault I added some debug code to the internal shell_exec function PHP_FUNCTION(shell_exec) { FILE *in; size_t total_readbytes; zval **cmd; char *ret; php_stream *stream; if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1

Is there any alternative for PHP exec(), shell_exec(), system(), passthrough() functions?

泄露秘密 提交于 2019-12-12 04:16:09
问题 Is there any alternative for PHP exec(), shell_exec(), system(), passthrough() functions? As all these functions have security risk, need a way to execute server commands without using any of these functions. Due to security reasons, can't enable these functions on my server php configuration. But as per website requirement, I need to execute some external commands like server ssh commands through php script. So, if there are any alternative ways to achieve same then please reply back to me.

How to run .sh script with php?

♀尐吖头ヾ 提交于 2019-12-12 03:46:15
问题 I am using raspberry pi 3(raspbian jessie) to capture image using fswebcam remotely using shell script and php. Since "motion" is running i need to stop the service then capture image and then restart it. #!/bin/bash DATE=$(date +"%Y-%m-%d_%H%M") sudo service motion stop fswebcam -r 640x480 --no-banner /var/www/html/sm/webcam/$DATE.jpg sudo service motion start The script works fine in terminal.Script is saved in var/www/html/sm. chmod +x webcam.sh also checked. I also wrote a php script to

shell_exec wont work from crontab

谁都会走 提交于 2019-12-12 03:16:50
问题 I have looked at other answers they dont fit to this case. I am using the full path to the file. Code I copied is simplified. run.php contains: shell_exec("php /var/www/html/sync/chourly.php $position $quotientx > /dev/null 2>/dev/null &"); if I use manually php run.php - it works great. here is the line on crontab -e : 05 * * * * /usr/bin/wget -O /dev/null http://sync.eeeww.com/run.php again the file run.php starts BUT chourly.php doesn't start. I am using centOS 6 any suggestions please?

PHP: mount USB device

戏子无情 提交于 2019-12-11 19:06:16
问题 I am writing a PHP script for the GUI of a Cent OS server. For testing purposes I have set up the Apache as localhost. Cent OS does not automount a connected USB device. In PHP I need to check if a USB device is plugged in then mount it and list the file content for the user. This is quite simple in bash, however I am unable to make it work in PHP. I have played around with both the exec() and the shell_exec() functions with no avail. I have tried the commands both manually i.e.: shell_exec(

Turn on shell_exec only for some hosts

淺唱寂寞╮ 提交于 2019-12-11 18:16:22
问题 i using nginx and php-fpm as default webserver without apache. So, for best security each host have own php-fpm pool. I am have a problem with shell_exec again - i no want to turn on for all users, but i need use this function for some host (1 or 3 hosts, no more). shell_exec is turned off in php.ini. I try to enable shell_exec in site php-fpm pool, but it's not working: php_admin_value[shell_exec] = on 回答1: Something else to consider is to disable the disable_function in the primary php.ini

Php Execute Shell Command and pipe the password

你。 提交于 2019-12-11 16:26:29
问题 I am attempting to run a command as root from a php page, is there any way to run shell_exec( su - root -c 'apt-get update' ) (for example) and pass the password to the shell? Or is there another way to run a root command from php and pass the password to the command. I would prefer not to do the follow: edit the /etc/sudoers file; install the ssh2 php extension; 回答1: You could create a setuid wrapper for the command you want to run, and execute that wrapper instead: echo '#!/bin/bash' >

PHP shell_exec update output as script is running

ぃ、小莉子 提交于 2019-12-11 11:45:41
问题 I'm using a script to get files from my server. I'm using aria2 to download the files quickly and it works great but is there a way when the script is running to output what is happening in the command. For example when you run this command via command line you get updates every couple of seconds $output = shell_exec('aria2c http://myserver.com/myfile.rar'); echo "<pre>$output</pre>"; I get these outputs: [#f6a7c4 9.5MiB/1.7GiB(0%) CN:15 SD:5 DL:431KiB ETA:1h9m9s] [#f6a7c4 52MiB/1.7GiB(2%) CN

PHP shell_exec() won't execute screen command to run .jar file

心不动则不痛 提交于 2019-12-11 09:17:54
问题 I am working on a minecraft control panel in Ubuntu and thus I need to start/stop a .jar filewith shell_exec(); When I try commands like "whoami", the output is normal. But when I try this: shell_exec("screen -dmS mcsrv java -Xmx512M -jar /var/www/srv/craftbukkit.jar -o true nogui"); It does not do anything, I have checked the permissions too and www-data is the owner of the files 回答1: Try to redirect the standard error stream to stdout (by appending 2>&1 to the command), fetch that output

Can I automatically locate the MySQL executable from PHP?

给你一囗甜甜゛ 提交于 2019-12-11 09:06:54
问题 I need to run Shell_exec to import a dump into my MYSQL database. Today I do this: $shellExec = 'C:\wamp\bin\mysql\mysql5.1.36\bin\mysql -h localhost -u root mertero_decicare < D:\localhost\sql\decisions.sql'; $out = shell_exec($shellExec .' 2> output'); Which works. But is there a way to 'find' the location of the mysql executable from PHP? SO I don't need to hardcaord my mysql location? Ron 回答1: An easy way to do this is add it to the Windows Environment path (it is in the path on most Unix