Quantcast
Viewing all articles
Browse latest Browse all 170995

bash script: calling pvesh within a loop exits after first iteration

Hello there,
I'm trying to write a bash script that will help me manage VMs automatically.
My goal is to manage VMs power status qutomatically, the approach is (within the bash script itself):
- run pvesh and get the cluster status, save the output to a tmp.file
- parse the tmp.file and load values of interesting VMs (any qemu and running VM)
- "build up" to a correct syntax a "pvesh get" status command, to check the VM status
- cycle to the next valid VM till EOF

So, if I run this script in "test" mode (i.e. just "build" a pvesh syntax in a $CMD variable then echo $CMD) the loop completes to EOF; if I execute the $CMD instead of just printing it, $CMD executes correctly for the first instance, then exits the loop as if EOF is reached.

Here is the script attached, please forgive my naif bash programming (and perhaps give me an hint to enhance it)

pvesh_script_sh.txt
Attached Files

Viewing all articles
Browse latest Browse all 170995

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>