VMware Cloud Community
Yunthor
Contributor
Contributor
Jump to solution

Problem with a perl script

Hello, I am trying to run this perl script. I hit enter and it sat there for a bit then just moved down a line and waited for another command. I put in some print commands to figure out where it is stopping, and my output is:

perl patchesx.pl

1

2

Here is the perl script I am using. Anyone know why it gets stuck on the $patchlist line?

#!/usr/bin/perl

  1. patchESX.pl -- auto update esx perl script

  2. by Vincent Vlieghe

  3. Version 6/03/2007

print "\n 1 \n";

use LWP::Simple;

print "\n 2 \n";

$patchlist = get 'http://xxx.xxx.xxx.xxx:8081/patcheslist.txt';

print "\n 3 \n";

@array = split(/\n/, $patchlist);

print "\n 4 \n";

foreach $item (@array)

{

print $item;

$item = trim($item);

$cmdQuery = "esxupdate query | grep ESX-$item";

if(system($cmdQuery) == 0)

{

print "\n$item is already installed - skipping\n";

}

else

{

print "\n$item is not yet installed - installing\n";

$cmdUpdate = "esxupdate -n -r http://xxx.xxx.xxx.xxx:8081/ESX-$item update";

system($cmdUpdate);

}

}

sub trim($)

{

my $string = shift;

$string =~ s/^\s+//;

$string =~ s/\s+$//;

return $string;

}

0 Kudos
1 Solution

Accepted Solutions
nirvy
Commander
Commander
Jump to solution

Hi,

If $patchlist is returning as undefined, it means the function failed. Have you enabled outbound http on the esx host? also, if authentication is required on that url you will need to do more than what you have currently got. It should eventually fail though and continue with your script with an undefined value for $patchlist

View solution in original post

0 Kudos
1 Reply
nirvy
Commander
Commander
Jump to solution

Hi,

If $patchlist is returning as undefined, it means the function failed. Have you enabled outbound http on the esx host? also, if authentication is required on that url you will need to do more than what you have currently got. It should eventually fail though and continue with your script with an undefined value for $patchlist

0 Kudos