You can now run scripts in the
\apps or
\samples directory or your
own scripts and pass in the session file using the
--sessionfile parameter as
follows.
<command> --sessionfile <sessionfile_location> <command_options>
For example:
perl hostinfo.pl --sessionfile C:\Temp\my_session
Note
If you
use a session file, any other connection parameters are ignored.
You can use the code in the
\apps\session\save_session.pl utility
application inside your own vSphere SDK for Perl application. If a call to the
server throws an exception, your application should terminate the session to
avoid session leaks. You could do this with an error handler that runs
disconnect() or
logout(), like in the
following example.
eval {
# ... insert program here ...
};
if ($@) {
print "Fatal error: $@";
Util::disconnect();
exit(1);
}
You can also use the
_END_ pseudo-signal
handler to perform a disconnect, as follows.
$SIG{__END__} = sub { Util::disconnect(); }
|