I have the following code (it's a snippet so it may seem silly, but altogether 
it would make sense as I am forcing one array into it for a test):

#!/usr/bin/perl -w
@DNS = ("/vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/Web & DNS (Win2003 
Std x32)/Web & DNS (Win2003 Std 
x32).vmx","/vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/Web & DNS (Win2003 
Std x32)/Disc1.vmdk","vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/Web & 
DNS (Win2003 Std x32)/Disc2.vmdk");

sub stop_it
{
                my $state = `/usr/bin/vmware-cmd \"$_[0]\" getstate -q`;
                chomp($state);
                if ($state == 'off') {
                                exit 1;
                }
                if ($state == 'paused') {
                                print "VM Paused, aborting backup for this vm";
                                $error_level = '1';
                                exit 1;
                }
                if ($state == 'on') {
                                'vmware-cmd $_[0] stop soft';
                                my $tools = `/usr/bin/vmware-cmd \"$_[0]\" 
gettoolslastactive -q`;
                                chomp($tools);
                }
                while (($state == 'on') && ($tools == 1)) {
                                sleep 30;
                                my $tools = `/usr/bin/vmware-cmd \"$_[0]\" 
gettoolslastactive -q`;
                                chomp($tools);
                }
}

stop_it(@DNS);

I am getting two errors I think, and I don't understand them.
The first is the second use of my $tools, how can I do this without causing an 
error? Can I just start using $tools right after without my?
The second I am sure is the darn () in the file names I am feeding into the 
function. Can someone shed some light :) I need to call the first indices of 
many arrays that get passed into this function, so I was thinking $_[0] was 
what I need. Problem is that the execution of vmware-cmd needs the value of 
$_[0] passed to it inside quotes.

Thanks!
jlc
jlc


Reply via email to