I am trying to execute an html function that will use a php file to run a linux bash script and shutdown a group of headless VMs. The bash script will successfully run on its own, but the php file is not executing the script. I made sure to add the correct line to sudoers.
#!/bin/bash
VM_NAME='wintgt1'
VBoxManage controlvm $VM_NAME poweroff
VM_NAME='wintgt2'
VBoxManage controlvm $VM_NAME poweroff
VM_NAME='wintgt3'
VBoxManage controlvm $VM_NAME poweroff
PHP
<?php
shell_exec("sudo /etc/init.d/portstop.sh");
header("Location: http://192.168.1.21/mod/page/view.php?id=133&forceview$");
?>
I have other scripts with the same sudoers entries and php files in the same location as this one. However, this particular php file is not executing the script. Thanks