VBoxManage guestcontrol execute.

Discussions related to using VirtualBox on Linux hosts.

VBoxManage guestcontrol execute.

Postby vamsi360 » 6. Apr 2012, 15:13

I have created a directory in Virutalbox.

Using VBoxManage, I am executing a script inside the Ubuntu VM directory I created above from Ubuntu host OS. But if the script in the VM contains commands for creating a new file, they are not executing. "echo" commands before and after the touch ommand are working fine.

I even used root user for VBoxManage to install. I think the directory is not allowing the files to be created . How can I make a directory in Linux to be 777 to all new files created automatically. I mean, even if I make the directory (chmod 777 dir), I am unable to execute the script from the host. Please help. It may be simple permissions problem. Even root is unable to execute.

VBoxManage guestcontrol "Ubuntu_10_04" execute --image "/bin/bash" "/home/cloudlet/Desktop/temp2/three" --username root --password root --verbose --wait-exit --wait-stdout -- -l /usr

Please help. I am struggling with this problem for the past one week.
vamsi360
 
Posts: 2
Joined: 6. Apr 2012, 15:12

Re: VBoxManage guestcontrol execute.

Postby Perryg » 6. Apr 2012, 16:03

Are the scripts executable?
ls -al in the folder
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: VBoxManage guestcontrol execute.

Postby vamsi360 » 6. Apr 2012, 18:18

^^ yes. The scripts are executable. I have given

chmod 777 script.sh

also to the script.
vamsi360
 
Posts: 2
Joined: 6. Apr 2012, 15:12

Re: VBoxManage guestcontrol execute.

Postby hot_weather » 25. Aug 2019, 01:28

I know I am coming to the party a bit late but maybe someone will see this. It's not enough to have the folder permissions 777, the files on the guest must be 777 (or rather executable). Adding executable files to your VM isn't allowed. You will notice when you copy the files from the host, the guest changes the permissions and they are no longer executable. However, adding files to a shared folder are executable (770) by default.

The VM must be turned off to add the shared folder. It might be possible to add it during an unattended install, I am not sure.
Code: Select all   Expand viewCollapse view
VBoxManage sharedfolder add "SomeVmNameHere" --name "my_shared_folder_name" --hostpath "/Users/me/Desktop/folder_i_want_to_share_on_host" --automount

within that folder, you have a script "run_me.sh"

You can now run
Code: Select all   Expand viewCollapse view
VBoxManage guestcontrol "SomeVmNameHere" run --exe "/media/my_shared_folder_name/run_me.sh" --username root --password MySuperSecurepAndCoolPassword

If you navigate to the shared folder inside the guest VM and run ls -al, you will notice that the files are all executable. This worked on Ubuntu 18.04 running Mate as the GUI.

If you are doing installations you might want to add your regular user to the sudoers list and not require passwords on "sudo dosomthing". You should be able to do this through a script run by root. That way not everything you install is owned by root. If you do that you should be able to execute files as a non-root user.

SIde note: to get into root I ran the command "su" in the terminal on my created user. It was a pain figuring that out.

In the Virtualbox manual chp 08 vboxmanage sharedfolder search for
"On Linux distributions, shared folders are mounted with 770 file permissions with root user and vboxsf as the group."

I hope this helps someone. Running an install script should allow you to change other file permissions. You may need to add "no pw required" on your user for other scripts to run without permission errors.
hot_weather
 
Posts: 1
Joined: 25. Aug 2019, 01:09


Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: No registered users and 9 guests