'PHP exec 'VBoxManage startvm'
I'm trying to start virtualbox machine throught PHP script on server. I wrote this script:
<?php
echo(exec("sudo VBoxManage startvm 'EnterToJa'"));
?>
And it runs on server, but it waits only for first line:
Waiting for VM "EnterToJa" to power on...
After that it probably kills it. When I run that VBoxManage command on my server from terminal it works, but I have to wait ~5 seconds and I this that is the problem.
P.S.
www-data <- has got permission to run sudo without password
Solution 1:[1]
To make your VirtualBox work you have to add into your command line |at now.
Example:
<?php
exec("sudo VBoxManage startvm 'EnterToJak' --type HeadLess|at now");
?>
Solution 2:[2]
Running this command in background should help in your case.
This should help:
exec("sudo VBoxManage startvm 'EnterToJa' &");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | richardec |
| Solution 2 | tracerout |
