Get session id of terminal to scrape

Discussions related to using VirtualBox on Windows hosts.
Post Reply
spatial
Posts: 4
Joined: 22. Aug 2017, 10:22

Get session id of terminal to scrape

Post by spatial »

Hi,
I am running Ubuntu on Windows and have a need to connect to the terminal emulator of Virtualbox' Unix from Java running on windows. This Java/C# code uses low-level EHLLAPI and its variants to connect to the emulator.
The test code is ready but I am trying to figure out how to connect. This type of connection is possible. Right ?


Thanks,
Mohan
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Get session id of terminal to scrape

Post by socratis »

I have no clue what you're talking about when you say "connect to the terminal emulator of Virtualbox' Unix". What do you mean, the console?
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
spatial
Posts: 4
Joined: 22. Aug 2017, 10:22

Re: Get session id of terminal to scrape

Post by spatial »

Yes. Is there a way to use an emulator between Windows and the local Unix and connect to that ? Windows Java code -> emulator -> VirtualBox.
It is like the Mainframe emulators.

ps -A -o "sess"
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Get session id of terminal to scrape

Post by scottgus1 »

If you mean, can you connect to the terminal inside the Ubuntu guest from a program running on the Windows host, then I think this can be done. You need to establish a network between the host and guest, just as if your Ubuntu guest was a real PC sitting next to your present physical PC.

In fact, this is the usual way to consider how to find a solution to a setup question with a Virtualbox guest: how would you solve the problem if the guest were a real PC somewhere? Solve the problem the same way with the Virtualbox guest, using the Virtualbox systems available.

See section 6 in the manual for the various kinds of networking Virtualbox provides, especially the table in section 6.2. You want communication between host and guest, at least. You may want internet in the guest, too. The easiest way to get this is Bridged, which puts the guest in the physical network the host is connected to. The guest gets an IP address on the host's network, and all the PCs in the network including the host can access the guest.

Bridged doesn't always work with Wi-Fi due to limitations in the Wi-Fi protocol. So if your physical PC's network is Wi-Fi (or if you aren't connected to a network at all), you may have to try the next best setup: Two guest networks, Host-Only to connect the host and guest, and NAT to get internet into the guest if your host has internet.

Once your host and guest can talk to each other, connect your Java thingy through the network to your Unix thingy and go to it!
spatial
Posts: 4
Joined: 22. Aug 2017, 10:22

Re: Get session id of terminal to scrape

Post by spatial »

I decided to test with VNC viewer to try to connect to it from the program. Ubuntu VNC is up. NAT is enabled with port 5901 forwarded.

TightVNCViewer in Windows host shows this message - Connection gracefully closed.

Is this setup properly ? Doesn't connect.

Guest IP is 127.0.0.1 and host IP is different.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Get session id of terminal to scrape

Post by scottgus1 »

OK, you're going to have to bone up on networking in general, and the Virtualbox networking types in particular. Did you read the manual?

You may be able to VNC into the guest through a port-forwarded NAT interface. but 127.0.0.1 is not the guest's true IP address, though the guest does show an "adapter" with 127.0.0.1 for an address. (google "loopback address").

The guest and host IP addresses should be different. IP addresses are like house addresses. If two houses have the same address, where does the mailman deliver the mail?

Assuming this is your only guest connected though NAT, try 10.0.2.15 for your guest's IP address in the VNC client on your host. (after you look through the manual you will see I didn't pull that IP address out of my hat... :) )
spatial
Posts: 4
Joined: 22. Aug 2017, 10:22

Re: Get session id of terminal to scrape

Post by spatial »

I tried that. But the last line in forums. virtualbox. org/viewtopic.php?f=1&t=36592 seems to mean that 'ifconfig' indeed shows the actual IP in the guest.

The VNC client doesn't connect using either IP.

C:\Users\spatial>C:\Oracle\VirtualBox\VBoxManage guestproperty get Mirage "/Vir
ualBox/GuestInfo/Net/0/V4/IP"
No value set!
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Get session id of terminal to scrape

Post by scottgus1 »

Put in CODE tags the text output of "ifconfig" in the guest, please.

Also, please attach the guest's .vbox 'recipe' file as a zip file, using the Upload Attachment tab under the textbox where you type new posts. You can find the guest's .vbox file by right-clicking the guest in the main Virtualbox window and choosing Show in Explorer. Be sure your host OS is set to show known extensions.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Get session id of terminal to scrape

Post by socratis »

spatial wrote:I decided to test with VNC viewer to try to connect to it from the program.
VirtualBox has a built in RDP server (VM Settings » Display » Remote Display). You may want to try that one instead of messing with the NAT and the port forwarding and the network. You can connect to each and every VM, even if doesn't have a network installed, because you connect to the host itself. So you could try rdp://localhost:3389

Just remember VNC is not RDP.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply