hi:
I have three vmware machine installed on VMware ESX server 4.0: redhat5, windows2003,vSphere Management Assistant (vMA).
when I run the shutdown script, the redhat5, windows2003 can be shutdown gracefully, but the vSphere Management Assistant (vMA) can not be shutdown
I think the VMs with spaces in the names, so do not shutdown properly.
For example the default name for the vMA appliance from VMware
/vmfs/volumes/******/vSphere Management Assistant (vMA)/ vSphere Management Assistant (vMA).vmx
Produces the following output from the script:
vim.fault.NotFound: No virtual machine found with name: /vmfs/volumes/*****/vSphere
vim.fault.NotFound: No virtual machine found with name: Management
vim.fault.NotFound: No virtual machine found with name: Assistant
vim.fault.NotFound: No virtual machine found with name: (vM/vSphere
vim.fault.NotFound: No virtual machine found with name: Management
vim.fault.NotFound: No virtual machine found with name: Assistant
vim.fault.NotFound: No virtual machine found with name: (vM.vmx
The script as below:
# Get the VM list
VMLIST=`/usr/bin/vmware-cmd -l`
for VM in $VMLIST
do
/usr/bin/vmware-cmd "$VM" stop trysoft
sleep 2
done
Somebody can help to fix my problem??
Thank you very much
yes, correct. can u make sure this by putting "echo $VM" inside the foreach loop. and one more i think, it will be like 7 cmd:
vmware-cmd "/vmfs/volumes/4c**/vSphere stop trysoft
vmware-cmd "Management" stop trysoft
vmware-cmd "Assistant" stop trysoft
vmware-cmd "(vMA)/vSphere" stop trysoft
vmware-cmd "Management" stop trysoft
vmware-cmd "Assistant" stop trysoft
vmware-cmd "(vMA).vmx" stop trysoft
Thanks,
Hi,
Try the following:
IFS="\012"
for VM in `/usr/bin/vmware-cmd -l` ; do
/usr/bin/vmware-cmd $VM stop trysoft
sleep 2
done
Good luck.
Regards
Franck
Hi jonesliu,
I don't know Bash Shell much, but here is my take on this.
Here is the line through which you are actually powering them down:
/usr/bin/vmware-cmd "$VM" stop trysoft
First of all, could you please tell, are the following 2 commands working in isolation?
/usr/bin/vmware-cmd "redhat5" stop trysoft
/usr/bin/vmware-cmd "vSphere Management Assistant (vMA)" stop trysoft
If it's working, we need to work on passing the argument correctly to the script.
Is there any way you can pass the argument in 3 separate parts to the script, as in,
/usr/bin/vmware-cmd double quotes & $VM & double quotes stop trysoft
In VBScript parlance, it will be like somecommand chr(32) & variable & chr(32)
chr(32) for printing/ passing the double quotes.
When we use \"$VM\" I guess we are passing double quotes alright, but the variable is not getting passed on.
Hi all:
I have try the command vmware-cmd "**.vmx" stop, all the guest OS can be shutdown gracefully.
So, the question is caused by the path of the VMs lack of the double quotes if use the command "/usr/bin/vmware-cmd $VM stop trysoft"
Now, I hope your help about how to add the double quotes to the path
the shutdown result is as below by the command "/usr/bin/vmware-cmd \"$VM\ stop trysoft"
Hi,
Can u try this shell script
Actually while saving vmx files in VMLIST it will separate the string using " " (space). So if ur VM name has any space means it will save as next element in array.
hi vijayagce:
---------Actually while saving vmx files in VMLIST it will separate the string using " " (space). So if ur VM name has any space means it will save as next element in array.
Is that to say when the script run the sentence "for VM in $VMLIST", it will separate the string by space.
for example:
the path of the VMs:/vmfs/volumes/4c**/vSphere Management Assistant (vMA)/ vSphere Management Assistant (vMA).vmx
it will separate to four VMs: "/vmfs/volumes/4c**/vSphere Management Assistant (vMA)/", "vSphere", "Management", "Assistant (vMA).vmx"
so the scripte will stop the VMs by the command:
vmware-cmd "/vmfs/volumes/4c**/vSphere Management Assistant (vMA)/" stop
vmware-cmd "vSphere" stop
vmware-cmd "Management" stop
vmware-cmd "Assistant (vMA).vmx" stop
:smileyconfused:
yes, correct. can u make sure this by putting "echo $VM" inside the foreach loop. and one more i think, it will be like 7 cmd:
vmware-cmd "/vmfs/volumes/4c**/vSphere stop trysoft
vmware-cmd "Management" stop trysoft
vmware-cmd "Assistant" stop trysoft
vmware-cmd "(vMA)/vSphere" stop trysoft
vmware-cmd "Management" stop trysoft
vmware-cmd "Assistant" stop trysoft
vmware-cmd "(vMA).vmx" stop trysoft
Thanks,
Hi vijayagce:
I have creat a new script, There is an error when I run the script
please refer to the attachment, I have post the content of the script and the result after running the script
for me its working fine. i think the "(" in vmx file path cause some prob. is this possible to u to rename the VM name which has "(" in vmx path?.
Yes, there is one guest OS named to "vSphere Management Assistant (vMA1) "
but I donot think it is the reason cause this problem
I have edit the vmxfilelist.txt, delete the line "/vmfs/volumes/4c*****/vSphere Management Assistant (vM_1/ vSphere Management Assistant (vM_1.vmx"
run the sentence:
cat vmxfilelist.txt | ( IFC=" "; while read VMX_FILE ; do CMD_OUTPUT=`/usr/bin/vmware-cmd "$VMX_FILE" stop trysoft` done)
the error :syntax error near unexpected token `) still exist
there must be some syntax error, for example, some unexpected character
I have verified the script again and again
Hi,
Can u try the command as below:
cat vmxfilelist.txt | ( IFC=" "; while read VMX_FILE ; do CMD_OUTPUT=`/usr/bin/vmware-cmd "$VMX_FILE" stop trysoft`
done)
I think below code will work with ur vSphere Management Assistant (vMA1) VM also: can u try this?
cat vmxfilelist.txt | ( IFC=" " || IFD="(" || IFE=")"; while read VMX_FILE ; do echo "$VMX_FILE"
Note: plz put "done)" in new line.
Thanks,
hi: vijayagce
a lot of thanks to you.
I just have put "done)" in new line. and try the script again, it works
The two guest OS "Windows XP Professional" and "vSphere Management Assistant (vMA1)" can be shutdown.
So, I have not tried your new method as below:
I think below code will work with ur vSphere Management Assistant (vMA1) VM also: can u try this?
cat vmxfilelist.txt | ( IFC=" " || IFD="(" || IFE=")"; while read VMX_FILE ; do echo "$VMX_FILE"
thank you very much!