PauseResume
Hi RujusMacBook ,
Here is a hacked together script from my original one.
It will loop through any virtual machines it finds and if running pause them,
then there is some space for your code and then it will loop through and resume them.
Or you can split the script in two.
Please post your final solution.
Cheers
Ben
#########################################################################################
# Parallels PauseResume #
# By Ben Harper #
# #
# Find all Parallels VMs and pause them, do something then go find and resume them #
# Ver 1.1 29/12/2011 - Hacked together from my shutdown #
# script for some dude on the interporn. #
#########################################################################################
#!/bin/bash
prlctl list -a --no-header --output name | while read line ; do # Pipe Parallels List of VM's to loop
VMName=$line # Get Name of VM
VMState=$(prlctl list --no-header -a -o status "$VMName"); #Better Way - no piping text
echo
echo Found - $VMName, State = $VMState
echo
if [[ $VMState == *running* ]] # If VM Running
then
echo $VMName was running, pausing it
prlctl pause "$VMName"
echo $VMName, State = $(prlctl list --no-header -a -o status "$VMName");
echo
fi
done
echo Do your backup here
echo Do your backup here
echo Do your backup here
echo Do your backup here
prlctl list -a --no-header --output name | while read line ; do # Pipe Parallels List of VM's to loop
VMName=$line # Get Name of VM
VMState=$(prlctl list --no-header -a -o status "$VMName"); #Better Way - no piping text
echo
echo Found - $VMName, State = $VMState
echo
if [[ $VMState == *paused* ]] # If VM Paused
then
echo $VMName was running, pausing it
prlctl resume "$VMName"
echo $VMName, State = $(prlctl list --no-header -a -o status "$VMName");
echo
fi
done
Last edited: Dec 28, 2011