The Comprehensive Perl Archive Network abbreviated as CPAN is as they themselves say "the gateway to all things perl". The site is home to thousands to perl modules going as far as 20 years & new modules are added regularly. In this short article we explore how to interact with the CPAN shell & seacrh for & install modules.
To invoke the CPAN shell type perl -MCPAN -e shell on the command line.
root@buntu:~# perl -MCPAN -e shell
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v2.11)
Enter 'h' for help.
cpan[1]>
At the CPAN prompt we can search for modules, get information on installed modules & install new modules.
To search for a module or a keyword we just need to type i followed by the keyword enclosed within forward slashes (//). For example, to search for SSH, just type:
cpan[1]> i /SSH/
Reading '/root/.cpan/Metadata'
Database was generated on Sat, 10 Dec 2016 10:53:26 GMT
Fetching with LWP:
http://www.cpan.org/authors/01mailrc.txt.gz
Reading '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
http://www.cpan.org/modules/02packages.details.txt.gz
Reading '/root/.cpan/sources/modules/02packages.details.txt.gz'
Database was generated on Wed, 14 Dec 2016 14:17:02 GMT
..............
New CPAN.pm version (v2.14) available.
[Currently running version is v2.11]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.
..............................................................DONE
Fetching with LWP:
http://www.cpan.org/modules/03modlist.data.gz
Reading '/root/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /root/.cpan/Metadata
Distribution BHEISIG/RT-Condition-NotStartedInBusinessHours-0.3.tar.gz
Distribution BNEGRAO/Net-SSH-Expect-1.09.tar.gz
Distribution SALVA/Net-OpenSSH-0.73.tar.gz
Distribution SALVA/Net-OpenSSH-Compat-0.09.tar.gz
Distribution SALVA/Net-OpenSSH-Parallel-0.14.tar.gz
Distribution SALVA/Net-SFTP-Foreign-Backend-Net_SSH2-0.09.tar.gz
Distribution SALVA/Net-SSH-Any-0.10.tar.gz
Distribution SALVA/Net-SSH2-0.63.tar.gz
Distribution SCHWIGON/Crypt-OpenSSH-ChachaPoly-0.02-reupload1.tar.gz
Distribution SCHWIGON/Net-SSH-Perl-2.01.tar.gz
Distribution SCOTTS/Net-SSH-W32Perl-0.05.tar.gz
Module < Net::CLI::Interact::Transport::Net_OpenSSH (OLIVER/Net-CLI-Interact-2.200006.tar.gz)
Module < Net::CLI::Interact::Transport::SSH (OLIVER/Net-CLI-Interact-2.200006.tar.gz)
Module < Net::DNS::RR::SSHFP (NLNETLABS/Net-DNS-1.06.tar.gz)
Module < Net::Dropbear::SSH (ATRODO/Net-Dropbear-0.10.tar.gz)
Module < Net::Dropbear::SSHd (ATRODO/Net-Dropbear-0.10.tar.gz)
Module < Net::LDNS::RR::SSHFP (CDYBED/Net-LDNS-0.75.tar.gz)
Module < Net::Netconf::Access::ssh (JUNIPER/Net-Netconf-1.04.tar.gz)
Module < Net::OpenSSH (SALVA/Net-OpenSSH-0.73.tar.gz)
Module = Net::OpenSSH::ConnectionCache (SALVA/Net-OpenSSH-0.73.tar.gz)
Module = Net::OpenSSH::ModuleLoader (SALVA/Net-OpenSSH-0.73.tar.gz)
Module = Net::OpenSSH::ObjectRemote (SALVA/Net-OpenSSH-0.73.tar.gz)
Module < Net::OpenSSH::Parallel (SALVA/Net-OpenSSH-Parallel-0.14.tar.gz)
Module < Net::OpenSSH::Parallel::Constants (SALVA/Net-OpenSSH-Parallel-0.14.tar.gz)
Module = Net::OpenSSH::SSH (SALVA/Net-OpenSSH-0.73.tar.gz)
Module < Net::SFTP::Foreign::Backend::Net_SSH2 (SALVA/Net-SFTP-Foreign-Backend-Net_SSH2-0.09.tar.gz)
Module = Net::SSH (IVAN/Net-SSH-0.09.tar.gz)
Module < Net::SSH2 (SALVA/Net-SSH2-0.63.tar.gz)
Module = Net::SSH2::Channel (SALVA/Net-SSH2-0.63.tar.gz)
Module < Net::SSH2::Cisco (VINSWORLD/Net-SSH2-Cisco-0.03.tar.gz)
Module = Net::SSH2::Dir (SALVA/Net-SSH2-0.63.tar.gz)
Module < Net::SSH2::Expect (JFRIED/Net-SSH2-Expect-0.2.tar.gz)
Module = Net::SSH2::File (SALVA/Net-SSH2-0.63.tar.gz)
Module = Net::SSH2::KnownHosts (SALVA/Net-SSH2-0.63.tar.gz)
Module = Net::SSH2::Listener (SALVA/Net-SSH2-0.63.tar.gz)
Module = Net::SSH2::PublicKey (SALVA/Net-SSH2-0.63.tar.gz)
Module = Net::SSH2::SFTP (SALVA/Net-SSH2-0.63.tar.gz)
Module < Net::SSH::Expect (BNEGRAO/Net-SSH-Expect-1.09.tar.gz)
Module < Net::SSH::Perl (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Cipher::RC4 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Comp (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Comp::Zlib (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Config (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Key (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Key::DSA (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Key::Ed25519 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Key::RSA (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Key::RSA1 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Mac (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Mac::MD5 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Mac::SHA1 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Mac::SHA2_256 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Mac::SHA2_512 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::Packet (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::ProxiedIPC (BDFOY/Net-SSH-Perl-ProxiedIPC-0.02.tar.gz)
Module < Net::SSH::Perl::Proxy (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::SSH1 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < Net::SSH::Perl::SSH2 (SCHWIGON/Net-SSH-Perl-2.01.tar.gz)
Module < SSH::Batch (AGENT/SSH-Batch-0.030.tar.gz)
Module < SSH::Batch::ForNodes (AGENT/SSH-Batch-0.030.tar.gz)
Module < SSH::Command (NRG/SSH-Command-0.07.tar.gz)
Author BKW ("Bernhard K. Weisshuhn" <bkw@cpan.org>)
Author BOSSHAPPY ("Jason Ungerleider" <CENSORED>)
Author SHAW ("sshaw" <shaw@cpan.org>)
\
I've trimmed a large portion of the output for brevity. We see three distinct entities in the matches for the keyword SSH. The distribution denotes groups of related modules, the module is the actual module itself & the Author section comprises of the authors associated with the creation and publication of the modules.
To get information on an installed module we just need to type the name of the module preceeded with the i character. For example:
cpan[2]> i Net::OpenSSH
Module id = Net::OpenSSH
CPAN_USERID SALVA (Salvador Fandino Garcia <salva@cpan.org>)
CPAN_VERSION 0.73
CPAN_FILE S/SA/SALVA/Net-OpenSSH-0.73.tar.gz
MANPAGE Net::OpenSSH - Perl SSH client package implemented on top of OpenSSH
INST_FILE /usr/share/perl5/Net/OpenSSH.pm
INST_VERSION 0.70
To install a module, type install followed by the module name. For example
cpan[4]> install Net::SSH::Perl::SSH2
Running install for module 'Net::SSH::Perl::SSH2'
Fetching with LWP:
http://www.cpan.org/authors/id/S/SC/SCHWIGON/Net-SSH-Perl-2.01.tar.gz
Fetching with LWP:
http://www.cpan.org/authors/id/S/SC/SCHWIGON/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/S/SC/SCHWIGON/Net-SSH-Perl-2.01.tar.gz ok
Scanning cache /root/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring S/SC/SCHWIGON/Net-SSH-Perl-2.01.tar.gz with Makefile.PL
This is Net::SSH::Perl.
As of version 1.00, Net::SSH::Perl supports both the SSH1 and
SSH2 protocols natively. The two protocols have different
module prerequisitives, so you need to decide which protocol(s)
you plan to use. If you use one or the other, only those modules
for your chosen protocol will be installed; if you choose both,
all of the supporting modules will be installed. Please choose
the protocols you'd like to use from the following list ("Both"
is the default).
[1] SSH1
[2] SSH2
[3] Both SSH1 and SSH2
Which protocol(s) do you plan to use? [3]
Checking for optional modules
Digest::BubbleBabble is required if you want to generate bubble babble
key fingerprints with pssh-keygen.
Would you like to install it? (y/n) [y] y
To make sure that dependent modules get installed while installing a module, type the following commands on the CPAN shell:
cpan[14]> o conf prerequisites_policy follow
prerequisites_policy [follow]
Please use 'o conf commit' to make the config permanent!
cpan[15]> o conf commit
Unknown config variable 'commitconf'
commit: wrote '/root/.cpan/CPAN/MyConfig.pm'
You would need to exit the CPAN shell & invoke it again in order for the changes to take effect.
No comments:
Post a Comment