I installed mytop but it won't run. It gives me the following error:

[root@daniweb root]# mytop
Can't locate Term/ in @INC (@INC contains: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at /usr/bin/mytop line 165.
[root@daniweb root]#

Apparently I don't have ReadKey installed? How can I get it? How difficult is it to install? Baby steps please! Thanks!

In addition to installing Term::ReadKey, how can I install Term:ANSIColor? Would I be able to see the color logged in remotely via SSH? (as the machine is quite a few states away from me!)

Dani AI

Generated

Quick summary and a few practical follow-ups.

The error you saw simply means Perl couldn’t find Term::ReadKey — the small terminal I/O module mytop uses to handle interactive keys. was right to point you toward CPAN, and as confirmed, installing Term::ReadKey solved the immediate problem. A couple of additional, still-useful options and troubleshooting tips follow.

Install options and build prerequisites

  • Easiest: use your distribution’s package for the module (package names vary by distro; Debian/Ubuntu typically uses libterm-readkey-perl, RHEL/CentOS names are similar).
  • From CPAN: use a CPAN client or cpanminus if you prefer newer tooling.
  • From source: make sure you have a C compiler and Perl headers before building (examples below).
# Debian/Ubuntu (build deps)
sudo apt-get install build-essential libperl-dev

# RHEL/CentOS (build deps)
sudo yum install gcc make perl-devel

Term::ANSIColor and SSH color output
Term::ANSIColor is pure-Perl and installs without a compiler. Colors will display over SSH as long as the local terminal supports ANSI escapes and your TERM environment variable is not set to a “dumb” terminal. Quick color test you can run over the SSH session:

printf '\033[31mThis should be red\033[0m\n'

If you see no color, check echo $TERM and, if appropriate, set a color-capable TERM (for example, xterm-256color) in your terminal emulator.

Extra troubleshooting

  • Verify where Perl thinks the module is installed: perldoc -l Term::ReadKey and perldoc -l Term::ANSIColor.
  • Make sure the shebang in the mytop script points to the same perl interpreter you installed modules for (different Perls = different @INC).
  • If installation fails with compile errors, re-check the build deps above or install via your distro package manager to avoid compiling.

If everything is installed but mytop still complains, mention the exact error and the output of perldoc -l Term::ReadKey and the mytop shebang — that narrows the remaining causes.

Recommended Answers

All 5 Replies

(suggestion)You need to install the missing module. Become root and type

perl -MCPAN -e 'install Term::ReadKey'

Without this module Perl has no mechanism to intercept the arrow key
presses and interpret them as requests to traverse the command line history.

I don't need to download this module from anywhere first? Just install it into Perl?

(suggestion)Let's make certain whether you have that module or not. Send the output of:

perl -MTerm::ReadKey -e 0
perl -dle 'print $INC{"Term/"}' # Then type 'c'
perl -MCPAN -le 'print $INC{"Term/"}'

Apparently I don't have ReadKey installed? How can I get it?

DOWNLOAD AVAILABLE

http://search.cpan.org/~ilyaz/Term-ReadLine-Perl-1.0203/
WHEN I FOUND THIS LINK I RAN ACROSS THIS STATEMENT
[quote=THE RUSSIAN First I installed Readline from(the link above)
Then ReadKey didn't work not yet (Error message after instaling) inspite
of has been in the Lib path ($INC). But the history worked
already.
To get rid of the ReadLine Error message I reinstalled Term::ReadKey
interactive via "perl -MCPAN -e shell". Now it works perfect! quote

I had to downloaded Term::ReadKey from the CPAN website. I untarred, compiled, and installed, and all works :)

Thank you! :-D

I untarred, compiled, and installed, and all works

I knew you didnt need baby steps!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.