1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#!/usr/bin/perl -w
#
# Copyright (c) 2007 VMware, Inc. All rights reserved.
use strict;
use CGI::Carp qw(fatalsToBrowser);
use warnings;
read(STDIN, my $donnees, $ENV{'CONTENT_LENGTH'});
my @champs_formulaire = split(/&/, $donnees);
my ($champ, $nom, $valeur);
my %formulaire;
foreach $champ (@champs_formulaire) {
(my $nom, my $valeur) = split(/=/, $champ);
$valeur =~ tr/+/ /;
$valeur =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$valeur =~ s/</</g;
$valeur =~ s/>/>/g;
$formulaire{$nom} = $valeur;
}
print "Content-type: text/html\n\n";
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">', "\n";
print "<html><head><title>CGI-Feedback</title></head>\n";
print "<body><h1>avis CGI du programme <i>essai.pl</i></h1>\n";
print "<p><b>server:</b> $formulaire{server}</p>\n";
print "<p><b>user:</b> $formulaire{user}</p>\n";
print "<p><b>password:</b> $formulaire{password}</p>\n";
print "</body></html>\n";
use warnings;
use FindBin;
use lib "$FindBin::Bin/../";
use VMware::VIM2Runtime;
use VMware::VILib;
$Util::script_version = "1.0";
Opts::parse();
Opts::validate();
Util::connect();
display_servertime();
Util::disconnect();
sub display_servertime {
Util::trace(0, "\nConnection Sucessful\n");
my $si_moref = ManagedObjectReference->new(type => 'ServiceInstance',
value => 'ServiceInstance');
my $si_view = Vim::get_view(mo_ref => $si_moref);
Util::trace(0, "Server Time : ". $si_view->CurrentTime()."\n");
}
__END__
=head1 NAME
connect.pl - connects and disconnects to a host.
=head1 SYNOPSIS
connect.pl [options]
=head1 DESCRIPTION
This VI Perl command-line utility connects to a host, retrieves the server
time and disconnects.
=head1 EXAMPLES
connect.pl --url https://<host>:<port>/sdk/vimService
--username myuser --password mypassword |
Partager