Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual page 236

Junos xml management protocol guide
Hide thumbs Also See for JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010:
Table of Contents

Advertisement

Junos 10.3 Junos XML Management Protocol Guide
214
# Check for password. If not provided, prompt for it
my $password = "";
if ($opt{p}) {
$password = $opt{p};
} else {
print STDERR "password: ";
ReadMode 'noecho';
$password = ReadLine 0;
chomp $password;
ReadMode 'normal';
print STDERR "\n";
}
In the first line of the preceding code sample, the script uses the Perl
read the hostname from the end of the command line. If the hostname is missing, the
script invokes the
output_usage
that a hostname is required:
my $hostname = shift || output_usage();
The script next determines which access protocol to use, setting the
the value of the
command-line option or to the value
-m
provided. If the specified value does not match one of the values defined by the
constant, the script invokes the
VALID_ACCESSES
usage message.
my $access = $opt{m} || "telnet";
use constant VALID_ACCESSES => "telnet|ssh|clear-text|ssl";
output_usage() unless (VALID_ACCESSES =~ /$access/);
The script then determines the username, setting the
-l
command-line option. If the option is not provided, the script prompts for it and uses
the
function (defined in the standard Perl
ReadLine
from the command line:
my $login = "";
if ($opt{l}) {
$login = $opt{l};
} else {
print STDERR "login: ";
$login = ReadLine 0;
chomp $login;
}
The script finally determines the password for the username, setting the
variable to the value of the
script prompts for it. It uses the
module) twice: first to prevent the password from echoing visibly on the
Term::ReadKey
screen and then to return the shell to normal (echo) mode after it reads the password:
my $password = "";
if ($opt{p}) {
$password = $opt{p};
} else {
print STDERR "password: ";
ReadMode 'noecho';
$password = ReadLine 0;
chomp $password;
subroutine to print the usage message, which specifies
output_usage
Term::ReadKey
command-line option. If the option is not provided, the
-p
function (defined in the standard Perl
ReadMode
shift
function to
variable to
$access
if the
option is not
telnet
-m
subroutine to print the
$login
variable to the value of the
module) to read it
$password
Copyright © 2010, Juniper Networks, Inc.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Junos os

Table of Contents