3

I am working on some coding, and I have an idea that should work but I have no clue how to make it work. I am using Wolfram Mathematica on my Windows host machine to run some code, but I have to export a file to a Linux-based program that I run in an Ubuntu Virtualbox VM. As of now, when the file is exported, I have to go over and click it to make it run.

While it's not too much work, I'd like to have it automated so that Mathematica can call my other program and I don't have to click anything. I've done my best to look around online for help, but honestly it's mostly over my head (I'm a civil engineer, not really computer savvy).

Here's what I've got so far:

C:\Program Files\Oracle\VirtualBox\VBoxManage guestcontrol "Ubuntu" execute --username (myname) --password (mypassword) --verbose --wait-exit --wait-stdout --image "/home/(myname)/Desktop/oof2-2.1.11/oof2"

It tells me VERR_ACCESS_DENIED and closes the guest session.

When I run my program in Ubuntu, all I have to do is type oof2 in the terminal window and it starts up, but how do I get it to do this via the command line? I've read through the guest control manual for VirtualBox and I didn't see anything that I can understand that directly applies. Any help is appreciated.

As a final note, I can run the examples given in the guest control manual and they work fine.

8
  • If you login to the Ubuntu machine from VirtualBox can you execute the app using the full path /home/(myname)/Desktop/oof2-2.1.11/oof2?
    – heavyd
    Jan 29, 2015 at 23:52
  • Well, I actually cannot. It initially said "access denied", so I did sudo ..., and it said "command not found". How do I find out which path the terminal is using? Again, I just type "oof2" and it pops up.
    – Hogy88
    Jan 30, 2015 at 0:07
  • try which oof2
    – heavyd
    Jan 30, 2015 at 0:10
  • The path is '/usr/local/bin/oof2'. Now I can type all of the script above but replace the --image "..." with --image "/usr/local/bin/oof2" and it runs, I think. It says the following: Process '...' started Process terminated Exit code=1 (status=500 [successfully terminated]) Closing guest session... This looks better, but I'm not quite sure what is the next step. If I type in '/usr/...' into the terminal, it brings up the GUI for oof2. I need to run the text version and get it to load a script (I type '/usr/local/bin/oof2 --text' in the terminal and it boots). Any ideas?
    – Hogy88
    Jan 30, 2015 at 0:34
  • oof2 --help or oof2 -h see if there is an option to pass it a script. But if you're trying to start a GUI application, you might have a hard time because VirtualBox is starting a new session for your user that wouldn't be associated with the current desktop.
    – heavyd
    Jan 30, 2015 at 0:36

1 Answer 1

1

Here is the help from the vboxmanage command:

 guestcontrol              <uuid|vmname>

                             exec[ute]
                             --image <path to program> --username <name>
                             [--passwordfile <file> | --password <password>]
                             [--domain <domain>] [--verbose] [--timeout <msec>]
                             [--environment "<NAME>=<VALUE> [<NAME>=<VALUE>]"]
                             [--wait-exit] [--wait-stdout] [--wait-stderr]
                             [--dos2unix] [--unix2dos]
                             [-- [<argument1>] ... [<argumentN>]]

So the full command should be:

C:\Program Files\Oracle\VirtualBox\VBoxManage guestcontrol "Ubuntu" execute --username (myname) --password (mypassword) --verbose --wait-exit --wait-stdout --image "/usr/local/bin/oof2" -- --text

Note the extra --. Everything after that will be passed as arguments to the process.


Setting Up SSH

  1. Install PuTTY on the host machine. (Direct link to installer)
  2. Open a terminal in the VM and type ip -4 addr. Look for your IP address, it'll be next to the word "inet" under the "eth0" section (probably going to be 10.0.2.XXX)
  3. From the VM window, open the "Device" menu, and select "Network"->"Network Settings". From there select "Port Forwarding"
  4. Add a rule, Host Port = 2222, Guest IP = , Guest Port = 22. Click OK on all dialogs.
  5. Run putty, use localhost as the hostname, and 2222 as the port. Click "Open"

If that works and you get a terminal, you can now use this command to run your application:

C:\Program Files (x86)\PuTTY\plink.exe -P 2222 -pw mypassword myname@localhost  "/usr/local/bin/oof2" --text
7
  • Do you have any knowledge about Python curses? It's giving me '_curses.error: endwin() returned ERR Process terminated'
    – Hogy88
    Jan 30, 2015 at 3:50
  • I don't, but I'd assume it has to do with running it this way. Have you tried running it over SSH instead?
    – heavyd
    Jan 30, 2015 at 4:00
  • I have not, and I don't know what that is yet (sorry...if you imaging Homer Simpson trying to code, I'm pretty close)
    – Hogy88
    Jan 30, 2015 at 4:02
  • No problem, it's a way of connecting over the network instead of through virtual box. Is the VM connected to the network? If so which network type is selected in VB (NAT, bridged, etc.)?
    – heavyd
    Jan 30, 2015 at 4:27
  • It's a NAT connection.
    – Hogy88
    Jan 30, 2015 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .