shell-exec

Using shell_exec('passwd') to change a user's password

谁说我不能喝 提交于 2019-12-04 04:26:22
问题 I need to be able to change the users' password through a web page (in a controlled environment). So, for that, I'm using this code: <?php $output = shell_exec("sudo -u dummy passwd testUser testUserPassword"); $output2 = shell_exec("dummyPassword"); echo $output; echo $output2; echo "done"; ?> My problem is that this script is not changing the password for the user "testUser". What am I doing wrong? Thanks 回答1: Another option is to have a shell script, say called passwd_change.sh somewhere

shell_exec and git pull

浪尽此生 提交于 2019-12-03 09:13:36
I was hoping someone could help, I have a PHP page which uses shell_exec to zip up a directory and run git pull to bring down recent repository changes. $op = shell_exec("cd /home/user/git/$repo/$dir/; zip -r /home/user/archives/$dir.$datestamp.zip $dir; cd /home/user/git/$repo/$dir/; git pull"); The zip works fine. If I change git pull to for example git log or git status - within my shell_exec, this works also, and I can see the log file. Just doesn't seem to like git pull. I saw another similar post to this, but wasn't sure how it was achieved >> Shell_exec with git pull? Mark Longair From

AWS CLI command works on Bash, but not with PHP shell_exec()

自闭症网瘾萝莉.ら 提交于 2019-12-02 12:18:21
问题 I would like to trigger the following command: aws route53 change-resource-record-sets --hosted-zone-id XXX --change-batch '{ "Comment": "2018-06-19-11:31", "Changes": [ { "Action": "CREATE", "ResourceRecordSet": { "Name": "example.com", "Type": "TXT", "TTL": 60, "ResourceRecords": [ { "Value": "\"something\"" } ] } } ] }' It works when I trigger it on bash, but not when I run it in PHP: $json = trim(shell_exec($cmd_aws_submit)); // or: $json = trim(shell_exec("{$cmd_aws_submit}")); AWS

AWS CLI command works on Bash, but not with PHP shell_exec()

╄→尐↘猪︶ㄣ 提交于 2019-12-02 04:10:57
I would like to trigger the following command: aws route53 change-resource-record-sets --hosted-zone-id XXX --change-batch '{ "Comment": "2018-06-19-11:31", "Changes": [ { "Action": "CREATE", "ResourceRecordSet": { "Name": "example.com", "Type": "TXT", "TTL": 60, "ResourceRecords": [ { "Value": "\"something\"" } ] } } ] }' It works when I trigger it on bash, but not when I run it in PHP: $json = trim(shell_exec($cmd_aws_submit)); // or: $json = trim(shell_exec("{$cmd_aws_submit}")); AWS expects, that the value ( "\"something\"" ) for the TXT record is quoted. I tried to quote it like this:

Bash script live output executed from PHP

廉价感情. 提交于 2019-12-02 02:47:23
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)) { echo fread($proc, 4096); @ flush(); } echo '</pre>'; ?> I have no output in my browser. I also

shell_exec returns empty string

时间秒杀一切 提交于 2019-12-02 02:12:51
问题 When I execute my command in PHP with shell_exec it always returns an empty string. I tried shell_exec('ls -l'); and it works. I put the command as a separate file and still same result. $shellOutput = shell_exec("pacmd list-sinks | grep 'volume: 0:' | tail -1 | awk '{ print $3 }'"); //return execute status; echo trim($shellOutput); 回答1: I changed the sudoers to ALL ALL = (ALL) :NOPASSWD ALL (very un-secure, but just to find something sure to work), then I did a sudo -u myusername /path/to

Running Linux Command from PHP

北城余情 提交于 2019-12-02 01:26:30
I have a bit of a unique situation. I'm trying to run a video encoding program from a PHP script called Diascope, which relies on the 'convert' command provided by ImageMagick. I have a bash script that executes a really simple conversion and then it runs the application called Diascope. This is the conversion code, and the following does work, it creates the new file convert image.jpg image.png Shows no errors, but then I run Diascope like this diascope -clean audio.txt And I can see that Diascope loads property because it prints "Diascope 0.2.1": diascope 0.2.1 (ms 2006-2010) slideshow

php shell_exec touch redirect and adduser

[亡魂溺海] 提交于 2019-12-02 01:20:14
I am trying to ultimately use php's shell_exec function to create new Linux users. I am, however, running into problems even with the debugging. Here is my code <?PHP function adduser($username,$password,$server){ try{ //3 debug statements $output=shell_exec("pwd"); echo $output; shell_exec("touch test.txt"); //3 debug statements are requested by Christian echo '<pre>'; print_r(execute('pwd')); print_r(execute('touch test.txt')); //actuall code $output=shell_exec("ssh root@$server \"adduser $username; echo $password | passwd $username --stdin\""); } catch(Exception $e){ echo 'could not add

shell_exec returns empty string

纵饮孤独 提交于 2019-12-01 21:16:25
When I execute my command in PHP with shell_exec it always returns an empty string. I tried shell_exec('ls -l'); and it works. I put the command as a separate file and still same result. $shellOutput = shell_exec("pacmd list-sinks | grep 'volume: 0:' | tail -1 | awk '{ print $3 }'"); //return execute status; echo trim($shellOutput); I changed the sudoers to ALL ALL = (ALL) :NOPASSWD ALL (very un-secure, but just to find something sure to work), then I did a sudo -u myusername /path/to/script.sh where script.sh has export VAR=value export VAR=value for all the environmental variables that are

Using shell_exec('passwd') to change a user's password

北城以北 提交于 2019-12-01 20:48:08
I need to be able to change the users' password through a web page (in a controlled environment). So, for that, I'm using this code: <?php $output = shell_exec("sudo -u dummy passwd testUser testUserPassword"); $output2 = shell_exec("dummyPassword"); echo $output; echo $output2; echo "done"; ?> My problem is that this script is not changing the password for the user "testUser". What am I doing wrong? Thanks Another option is to have a shell script, say called passwd_change.sh somewhere that looks like this: #!/usr/bin/expect -f set username [lindex $argv 0] set password [lindex $argv 1] spawn