VMware {code} Community
SoMoS
Contributor
Contributor

How to check for directory existence with vmrun?

Hello,

I'm porting an existing VIX interface to use vmrun and I cannot find the way to use the DirectoryExistsInGuest with vmrun. Could be that VMware developers forgot it? Is there a workaround?

Thanks in advance.

0 Kudos
10 Replies
verminator
Enthusiast
Enthusiast

What version of VIX are you using. VIX, as far back as release 1.6.2 has an API for checking directory existence. This is also supported in subsequent releases: http://www.vmware.com/support/developer/vix-api/vix16_reference/lang/c/functions/VixVM_DirectoryExis...

This particular API is supported on all VMWare platforms, except for VMWare Server 1.0 (as indicated here)

http://www.vmware.com/support/developer/vix-api/vix110_reference/index2.html

0 Kudos
SoMoS
Contributor
Contributor

Of course exists in VIX.

As I said I'm porting a VIX interface to a vmrun interface, so I need to execute the VIX DirectoryExistsInGuest with VMRUN. I already did it with VIX.

Feel free to ask me if something is still not clear.

0 Kudos
stanguturi
VMware Employee
VMware Employee

vmrun is not a 1:1 mapping of the VIX API, but this is a good request, and we will look at adding this new option to vmrun in the next release.

-Thanks

Sankar.

0 Kudos
SoMoS
Contributor
Contributor

Ok, I see.

In my humble opinion vmrum should be a 1:1 mapping with VIX because looks like the tool is there to help people that does not want to develop an application and prefers to create a script. If you can't do the task because you're missing some functionality at the end you will have to use VIX.

Other missing things I've found that stops me from using vmrun as a replacement of VIX:

- GetPowerState.

- ReadingEnvVariables does not work.

- You have no way of knowing if executeProgramAtGuest has succeded or not as you don't get the exit code of the executed program.

Anyway thanks a lot for your answer, is way more that what I usually get here.

0 Kudos
stanguturi
VMware Employee
VMware Employee

> - GetPowerState.

You can use "vmrun list" command which will give a list of all running VMs. You can check if the list contains the required VM.

> - ReadingEnvVariables does not work.

What is the exact issue that you encountered with this option?

0 Kudos
stanguturi
VMware Employee
VMware Employee

> - You have no way of knowing if executeProgramAtGuest has succeded or  not as you don't get the exit code of the executed program.

What version of vmrun are you using?  When you execute a program using vmrun via "runprograminguest" option, vmrun prints the errorcode on the console if the program terminates with a non-zero exit code in the guest. Also, vmrun returns the errorcode back to the caller.

-Thanks

Sankar.

SoMoS
Contributor
Contributor

>> - GetPowerState.

>>You can use "vmrun list" command which will give a list of all running VMs. You can check if the list contains the required VM.

Thanks for the hint. Even it is a good idea still is no replacement of PowerState as I cannot know if it's stopped or stopping or starting ...

>> - ReadingEnvVariables does not work.

>What is the exact issue that you encountered with this option?

You have the issue here: http://communities.vmware.com/message/1723867#1723867

Anyway the problem is I can only read variables that I've written before, no real guest environment variables (like path or whatever).

0 Kudos
SoMoS
Contributor
Contributor

>> - You have no way of knowing if executeProgramAtGuest has succeded or  not as you don't get the exit code of the executed program.

>What version of vmrun are you using?  When you execute a program using vmrun via "runprograminguest" option, vmrun prints the errorcode on the console if the program terminates with a non-zero exit code in the guest. Also, vmrun returns the errorcode back to the caller.

I'm running 1.10.2. When I execute the runprograminguest what I get is some output (maybe the stderr printed by the executed app) and a -1 return code so I have no way of knowing if the one that failed was vmrun or the executed app (and I'm losing the original errorcode by the way).

Thanks for helping!

0 Kudos
stanguturi
VMware Employee
VMware Employee

> I'm running 1.10.2. When I execute the runprograminguest what I get is  some output (maybe the stderr printed by the executed app) and a -1  return code so I have no way of knowing if the one that failed was vmrun  or the executed app (and I'm losing the original errorcode by the way).

If the program fails inside the guest, then vmrun captures the return value of the guest program and returns it back to the caller. Also when the program fails inside the guest, vmrun prints the following:

Guest program exited with non-zero exit code:<returnerror code of the guest program>

If you received -1 error and didn't see the above message, then the error is related to vmrun.

-Thanks

Sankar.

0 Kudos
stanguturi
VMware Employee
VMware Employee

The latest version of vix (1.11) was released few days back. Download the latest vix bundle from http://bit.ly/vixapi. Check the release notes at https://www.vmware.com/support/developer/vix-api/VIX-1.11-ReleaseNotes.html#NewFeatures

We have added a new option "directoryExistsInGuest" to vmrun. This should solve your problem.

-Thanks

Sankar.

0 Kudos