Home > Blockchain >  virt-viewer open multiple windows with bash script
virt-viewer open multiple windows with bash script

Time:06-27

I've got a few virtual machines running that can be observed with virsh list --all

 Id   Name         State
-----------------------------
 1    vm-bigfg-1   running
 2    vm-nexus-1   running
 -    vm-jumph-1   shut off
...

Executing virt-viewer --connect qemu:///session --wait vm-bigfg-1 will open a new virt viewer window, how do I chain these commands into a script that opens many virt-viewer windows?

I've tried variations of a script shown below, each time only the first virt-viewer will open.

bash -c 'virt-viewer --connect qemu:///session --wait vm-bigfg-1-1' 
bash -c 'virt-viewer --connect qemu:///session --wait vm-nexus-1' 
bash -c 'virt-viewer --connect .....'

Also,

/bin/sh -ce 'virt-viewer ..... `

Many thanks in advance

CodePudding user response:

Use the ampersand character to tell the shell to put the command into the background

bash -c 'virt-viewer --connect qemu:///session --wait lab-node-1 &'

  • Related