Need to solve "Can't locate VMware/VIRuntime.pm" in cygwin - vmware

I have a (maybe) unusual situation. I need to run VMware CLI commands in a Windows box, but via the cygwin CLI inside a shell script. I can NOT change this for now, so any suggestions to "why not do this instead" may be futile, although appreciated. Here's a sample script.
#!/bin/bash
# Paths for vmware-cmd.pl file to run vmware commands from vsphere cli
_vcli_dir="/cygdrive/c/Program Files (x86)/VMware/VMware vSphere CLI"
_vcli_bin="$_vcli_dir/bin"
_vcli_perl="$_vcli_dir/Perl"
_vcli_perl_bin="$_vcli_perl/bin"
_vcli_perl_lib="$_vcli_perl/lib"
_vcli_perl_vlib="$_vcli_perl_lib/VMware"
_vcmd=vmware-cmd.pl
export _orig_path=$PATH
# Add above directories to path variable
export PATH=$PATH:$_vcli_dir:$_vcli_bin:$_vcli_perl:$_vcli_perl_bin:$_vcli_perl_lib:$_vcli_perl_vlib
echo $PATH
$_vcmd /?
export PATH=$_orig_path
echo $PATH
When I run the above script, I get
Can't locate VMware/VIRuntime.pm in #INC (#INC contains:
/usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int
/usr/lib/perl5/site_perl/5.14
/usr/lib/perl5/vendor_perl/5.14/i686-cygwin-threads-64int
/usr/lib/perl5/vendor_perl/5.14
/usr/lib/perl5/5.14/i686-cygwin-threads-64int /usr/lib/perl5/5.14
/usr/lib/perl5/site_perl/5.10 /usr/lib/perl5/vendor_perl/5.10
/usr/lib/perl5/site_perl/5.8 .) at /cygdrive/c/Program Files
(x86)/VMware/VMware vSphere CLI/bin/vmware-cmd.pl line 8. BEGIN
failed--compilation aborted at /cygdrive/c/Program Files
(x86)/VMware/VMware vSphere CLI/bin/vmware-cmd.pl line 8.
I can run the same vmware-cmd.pl script from a DOS command prompt
c:> vmware-cm.pl
So I now my installation is correct.
Any clues please?

This post gave me the idea to fix it. But now I get a core dump.
How is Perl's #INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)
The added line is the second export PERL5LIB line.
#!/bin/bash
# Path for vmware-cmd.pl file to run vmware commands from vsphere cli
_vcli_dir="/cygdrive/c/Program Files (x86)/VMware/VMware vSphere CLI"
_vcli_bin="$_vcli_dir/bin"
_vcli_perl="$_vcli_dir/Perl"
_vcli_perl_bin="$_vcli_perl/bin"
_vcli_perl_lib="$_vcli_perl/lib"
_vcli_perl_vlib="$_vcli_perl_lib/VMware"
_vcmd=vmware-cmd.pl
export _orig_path=$PATH
# Add above directories to path variable
export PATH=$PATH:$_vcli_dir:$_vcli_bin:$_vcli_perl:$_vcli_perl_bin:$_vcli_perl_lib:$_vcli_perl_vlib
export PERL5LIB=$_vcli_dir:$_vcli_bin:$_vcli_perl:$_vcli_perl_bin:$_vcli_perl_lib:$_vcli_perl_vlib
echo $PATH
$_vcmd /?
export PATH=$_orig_path
echo $PATH

I solved by going through my elbow to get to my a**, as the saying goes.
What I did was
- Install vmware cli on my Windows box to the default directory
- Added environment variables for the VMware main directory, the bin directory, the Perl directory and the Perl/bin directory
- Added these environment variables to my PATH variable.
Then I created a vmware-cli.bat file that takes parameters and concatenates them into a vmware-cli command with the correct values. For example, I call this to list the VMs in the server
cygwin:> ./vmware-cli.bat vmware-cmd.pl --server MyServer --username User --password PW -l
Inside the batch file I essentailly do
REM Get first parm as the command, and then concatenate the rest of the parms
set VCLI_CMD=%1
shift
:LOOP
if %1x==x goto :EXECUTE
set VCLI_CMD=%VCLI_CMD% %1
shift
goto LOOP:
:EXECUTE
%VCLI_CMD%

This is an alternative to the previous posted that will allow you to keep it in the same shell script
VIMCMD="/cygdrive/C/Program Files (x86)/VMware/VMware vSphere CLI/bin/vmware-cmd.pl"
VIMCMD_DOS=$(cygpath -d "$VIMCMD")
DOS_VIMCMD="cmd /c $VIMCMD_DOS"
Then you can run:
$ $DOS_VIMCMD --version
vSphere SDK for Perl version: 6.0.0
Script 'vmware-cmd.pl' version: 6.0.0

Related

Failed to start a TensorBoard session in vscode due to the following error:

To launch tensorboard in vscode, I did the following steps:
select a python interpreter path
choose Python:Launch TensorBoard
and then I get this error:
We failed to start a TensorBoard session due to the following error: Command failed: conda activate ldl && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/cxy/.vscode-server/extensions/ms-python.python-2022.18.2/pythonFiles/printEnvVariables.py
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with
$ echo ". /home/cxy/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
or, for all users, enable conda with
$ sudo ln -s /home/cxy/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh
The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH. To do so, run
$ conda activate
in your terminal, or to put the base environment on PATH permanently, run
$ echo "conda activate" >> ~/.bashrc
Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file. You should manually remove the line that looks like
export PATH="/home/cxy/anaconda3/bin:$PATH"
^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^
I have tried the suggested command, which is
echo ". /home/cxy/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
but it doesn't work, I still get the same error.
How can I solve this problem? Is there any suggestion? thanks in advance!!!
I have solved this problem!!!
Basically, it is caused by the latest version of Python and Pylance extension in vscode, all we have to do is simply downgrade the two extensiona and make sure vscode won't update them automatically.
So, do the following:
Downgrade Python extension and Pylance extension to eariler version, like v2021.10.xx and v2021.10.0 respectively.
Close the extension auto update in vscode, to ensure the downgradion in step1 works after restarting vscode.
Specifically, openSettings and search for the keyword update, do the following:
2.1. beneath the Update: Mode,select None instead of default
2.2. beneath the Extensions: Auto Update, select None instead of All extensions
After I did the above steps, the problem just disappeared. I can then launch tensorboard by shift+cmd+P and select Python:Launch TensorBoard.

Environment variable error while trying to create a solver in OpenFOAM 9

I'm trying to create a solver in my /opt/OpenFOAM/OpenFOAM-9/applications/solvers/electromagnetics directory using sudo foamNewSource App newSolver. But, I keep getting the following error:
foamNewSource: Creating new interface file newSolver.C
wmakeFilesAndOptions error: environment variable $WM_OPTIONS not set
And then, although I can see a newSolver.C file, I cannot see a Make directory and neither the rest of the files.
I'm running EndeavourOS Linux x86_64 with kernel 5.15.6-arch2-1 and shell bash 5.1.12. I installed the openfoam-org package from the AUR, and in order to set it up, I have the following in my .bashrc config file:
source /opt/OpenFOAM/OpenFOAM-9/etc/bashrc
At first, when I did env | grep WM I couldn't find WM_OPTIONS in my system. So, after googling a little bit, I added this to my .bashrc file:
source /opt/OpenFOAM/OpenFOAM-9/etc/bashrc
export WM_OPTIONS=linux64GccDPOpt
And now, doing env | grep WM I get:
WM_COMPILER=Gcc
WM_PRECISION_OPTION=DP
WM_PROJECT_USER_DIR=/home/username/OpenFOAM/username-9
WM_MPLIB=SYSTEMOPENMPI
WM_OPTIONS=linux64GccDPOpt
WM_ARCH=linux64
WM_LABEL_SIZE=32
WM_PROJECT=OpenFOAM
WM_THIRD_PARTY_DIR=/opt/OpenFOAM/ThirdParty-9
WM_LABEL_OPTION=Int32
WM_CC=gcc
WM_CFLAGS=-m64 -fPIC
WM_LINK_LANGUAGE=c++
WM_OSTYPE=POSIX
WM_PROJECT_VERSION=9
WM_DIR=/opt/OpenFOAM/OpenFOAM-9/wmake
WM_ARCH_OPTION=64
WM_CXXFLAGS=-m64 -fPIC -std=c++0x
WM_PROJECT_INST_DIR=/opt/OpenFOAM
WM_LDFLAGS=-m64
WM_CXX=g++
WM_COMPILE_OPTION=Opt
WM_PROJECT_DIR=/opt/OpenFOAM/OpenFOAM-9
WM_COMPILER_TYPE=system
WM_COMPILER_LIB_ARCH=64
Now I can see the WM_OPTIONS environment variable (just above WM_ARCH=linux64 and below WM_MPLIB=SYSTEMOPENMPI), but I still get the same wmakeFilesAndOptions error.
I don't know what configuration I'm messing up, so I'd appreciate some help!
Thanks!
Using sudo in this case is not a good idea, instead run the scripts on your home directory:
mkdir -p $FOAM_RUN
cd $FOAM_RUN
foamNewSource App newSolver
For WM_OPTIONS environment variable, don't set it manually, instead use:
export WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION

Calabash Android custom folder for step definitions

I'm running calabash-android command in macOS. I would like to specify custom folder for step_definitions and support files.
ex:
calabash-android run path_to_app.apk -x path_to_steps_folder
features_folder`
-x path_to_steps_folder - cannot locate this option.
"Calabash-android run" will forward command line options to cucumber. The cucumber option to require a file is -r. So this should work for you:
calabash-android run path_to_app.apk -r path_to_steps_folder features_folder

python not accessible in powershell v3 when opened with Popen

Hopefully this should be simple. Python environment is running fine if I open PowerShell v3 manually. I can check version and run external scripts etc. But as soon as I open powershell.exe through subprocess.Popen from a python script from another application, python simply won't run; "The term 'Python' is not recognised as the name of a cmdlet, function, script file or operable program... etc"
I've checked my environment paths repeatedly and python is running fine on the system in general.
anyone has any idea what this could be caused by?
subprocess.Popen(["powershell.exe", '-ExecutionPolicy', 'RemoteSigned', "path to PS1_script_with python command"])
My PS1 file looks like this:
cd C:\Users\David\Geeknote\geeknote-master\geeknote
python gnsync.py --path "C:\Users\David\Desktop\C4DtoEvernote", --mask "*.nfo", --notebook "Python Logs"
function Pause{Read-Host 'You have successfully synced your C4D Annotations to Evernote using gnsync.
Please press Enter to continue...' | Out-Null}
Pause{}
It seems (for whatever reason) your $PATH is not being read or honored by the process; and thus python cannot be found.
You can either:
Set up the path with $env:Path = "C:\Python27:C:\Python27\Scripts";
Setup the path using a custom console profile (ie, a .ps1 file) and passing it with -PSConsoleFile.
The simplest option, pass the full path to the Python executable in your command file C:\Python27\python.exe gsync.py ...
I would try #3, and then see if you need the other options.
Adjust the paths as appropriate - especially if you have multiple Python interpreters installed.

Using wget or curl with a changing name file

First of all please excuse my bad english, I'll try to get understandable.
I'm using a batch file (Windows, cmd.exe) to retrieve and silently install Adobe Flash on my computer.
The batch works well, but I have a problem when there is a major version change on Adobe servers.
Here is the command line batch:
#echo off
setlocal enableextensions
md c:\temp\flash
pushd c:\temp\flash
wget -nH --cut-dirs=5 -r --timestamping http://download.macromedia.com/get/flashplayer/current/licensing/win/install_flash_player_15_plugin.exe
wget -nH --cut-dirs=5 -r --timestamping http://download.macromedia.com/get/flashplayer/current/licensing/win/install_flash_player_15_active_x.exe
echo Closing browsers
pause
taskkill /f -im firefox.exe -im iexplore.exe
install_flash_player_15_plugin.exe -install -au 2
install_flash_player_15_active_x.exe -install -au 2
popd
setlocal disableextensions
pause
When Flash is upgraded to the next version, the filename changes from install_flash_player_15_active_x.exe
to
install_flash_player_16_active_x.exe
and the batch must be manually corrected or else it is stuck with an old version.
Is there any way to replace the version number with wildcards or some regular expression in order to have wget to retrieve the latest file when its name change ?
Or at least, is there any Windows compatible command line tool which parses the file names on a server, find the latest and passes it as a variable for wget (or cURL) ?
Thank you
You don't need Regular Expressions to get the current version of flash for IE and Firefox. Just change the URLs to
For Firefox: http://download.macromedia.com/pub/flashplayer/current/support/install_flash_player.exe
For IE: http://download.macromedia.com/pub/flashplayer/current/support/install_flash_player_ax.exe
wget -nH --cut-dirs=5 -r --timestamping http://download.macromedia.com/pub/flashplayer/current/support/install_flash_player.exe
wget -nH --cut-dirs=5 -r --timestamping http://download.macromedia.com/pub/flashplayer/current/support/install_flash_player_ax.exe