VMware {code} Community
Homer21
Contributor
Contributor

Run a Linux Shell via VM API?

Hi All,

Is there anyway that I can run a guest linux shell command using VMWare API (or any other SDKs) and return the result back to my Java code?

I have Linux installed on my ESX4.1. I want to run a code to run something in that Linux guest OS.

Thanks in advance,

Homer

Tags (4)
0 Kudos
4 Replies
togtog
Hot Shot
Hot Shot

Hi Homer!

When working with ESX 4.1 there are two different routes I can think of:

  1. The VMware VIX API providing amongst others routines which enable you to run programs in a guest in a transparent way. Unfortunately the VIX API is only available for C, Perl and COM, i.e. no direct Java access. Yet there is a fling from the VMware labs - VIX Java Toolkit - which provides a Java interface to the VIX API. I have not work with it yet but may be you wanna give it a try.
  2. As you are trying to run a shell command in a linux guest you can use any SSH Java client to connect to the linux guest - e.g. Ganymed SSH

Finally be aware of the fact that in ESXi 5 VIX API has been depreceated and equivalents have been established in the vSphere API through Managed objects GuestAuthManager, GuestFileManager, GuestOperationsManager, and GuestProcessManager which you can find here.

Hope this helps ...

Thomas G.
0 Kudos
Homer21
Contributor
Contributor

Thanks Thomas for your very useful info. The reason that I can't use SSH is I am trying to implement a piece of code to simulate typing in Console.

Commands that I want to run can not be run from outside SSH sessions (only can be initiated from Console).

I will see if I can upgrade our servers to 5 so I can use the API you mentioned (Do you know by any chance a sample code somewhere?)

Thanks,

Homer

0 Kudos
lamw
Community Manager
Community Manager

Take a look at my blog article here http://www.virtuallyghetto.com/2011/07/automating-new-integrated-vixguest.html which has a complete working sample script for the new Guest Operations using the vSphere API via vSphere SDK for Perl.

0 Kudos
ii00907
Contributor
Contributor

Sono assente, leggero' la posta al mio ritorno, il 27/08/2012.

I am absent, I will read the email on my return, 27/08/2012.

-- Disclaimer

0 Kudos