Vielen Dank für eure Unterstützung! Ich habe meinen Code um die Vorschläge erweitert und es funktioniert genauso, wie ich es mir vorgstellt habe. Für alle die es noch interessiert und auch gerne ESXi Server updaten wollen hier das Script:
Code:
#!/usr/bin/perl
use Term::ReadKey;
my @patches = glob("/vmware-updates/ESXi/*.zip");
system ("clear");
print "########################################################################################################
########################################ESX server patch utility########################################
########################################################################################################
#This program can query or update ESX and ESXi servers. #
#Following options are available: : #
# 1 = List installed patches of a ESX server #
# 2 = Install all patches of repository /vmware_updates/ESXi #
########################################################################################################\n";
print "Choose an option from list above: ";
chomp ($select = <STDIN>);
while ($select ne '1' && $select ne '2') {
print "Undefined input!!!\n";
print "Please choose again: ";
chomp($select = <STDIN>);
}
#List all patches
if ($select eq '1') {
print "Server to connect: ";
chomp ($server = <STDIN>);
system ("vihostupdate -q --username root --server $server");
}
#Install patches from /vmware-updates/ESXi
if ($select eq '2') {
print "Server to connect: ";
chomp ($server = <STDIN>);
chomp ($key = 0);
print "Type password: ";
chomp ($password = "");
ReadMode(4);
while(ord($key = ReadKey(0)) != 10)
{
# For all value of ord($key) see http://www.asciitable.com/
if(ord($key) == 127 || ord($key) == 8) {
# DEL/Backspace was pressed
chop($password);
#2 move the cursor back by one, print a blank character, move the cursor back by one
print "\b \b";
} elsif(ord($key) < 32) {
# Do nothing with these control characters
} else {
$password = $password.$key;
print "*";
}
}
#Ignore additional characters in passwords
$password = quotemeta($password);
ReadMode (0);
# $_ is return value of @patches
foreach (@patches) {
system "vihostupdate --server $server update --username root --password $password -i -b $_ --verbose";
}
}
Lesezeichen