perl dancer 基础6

2022-03-25 17:24:04 浏览数 (1)

安装Expect

可以使用下面方法安装

cpanm

代码语言:javascript复制
cpanm Expect

CPAN shell

代码语言:javascript复制
perl -MCPAN -e shell
install Expect

或直接在cpan中进行安装

代码语言:javascript复制
cpan[2]> install Expect
CPAN: Storable loaded ok (v2.20)
CPAN: LWP::UserAgent loaded ok (v5.833)
CPAN: Time::HiRes loaded ok (v1.9721)
Fetching with LWP:
  http://mirrors.163.com/cpan/authors/01mailrc.txt.gz
CPAN: YAML loaded ok (v1.15)
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
  http://mirrors.163.com/cpan/modules/02packages.details.txt.gz
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Thu, 26 Nov 2015 22:41:02 GMT
..............
  New CPAN.pm version (v2.10) available.
  [Currently running version is v1.9402]
  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://mirrors.163.com/cpan/modules/03modlist.data.gz
Going to read '/root/.cpan/sources/modules/03modlist.data.gz'
DONE
Going to write /root/.cpan/Metadata
Running install for module 'Expect'
Running make for S/SZ/SZABGAB/Expect-1.32.tar.gz
Fetching with LWP:
  http://mirrors.163.com/cpan/authors/id/S/SZ/SZABGAB/Expect-1.32.tar.gz
CPAN: Digest::SHA loaded ok (v5.47)
Fetching with LWP:
  http://mirrors.163.com/cpan/authors/id/S/SZ/SZABGAB/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/S/SZ/SZABGAB/Expect-1.32.tar.gz ok
Scanning cache /root/.cpan/build for sizes
DONE
CPAN: Archive::Tar loaded ok (v1.58)
Expect-1.32/
Expect-1.32/.perltidyrc
Expect-1.32/.travis.yml
Expect-1.32/Changes
Expect-1.32/examples/
Expect-1.32/lib/
Expect-1.32/Makefile.PL
Expect-1.32/MANIFEST
Expect-1.32/META.json
Expect-1.32/META.yml
Expect-1.32/README.md
Expect-1.32/t/
Expect-1.32/tutorial/
Expect-1.32/tutorial/1.A.Intro
Expect-1.32/tutorial/2.A.ftp
Expect-1.32/tutorial/2.B.rlogin
Expect-1.32/tutorial/3.A.debugging
Expect-1.32/tutorial/4.A.top
Expect-1.32/tutorial/5.A.top
Expect-1.32/tutorial/5.B.top
Expect-1.32/tutorial/6.A.smtp-verify
Expect-1.32/tutorial/6.B.modem-init
Expect-1.32/tutorial/README
Expect-1.32/t/01-test.t
Expect-1.32/t/02-bc.t
Expect-1.32/t/03-log.t
Expect-1.32/t/04-multiline.t
Expect-1.32/t/10-internal.t
Expect-1.32/t/11-calc.t
Expect-1.32/lib/Expect.pm
Expect-1.32/examples/calc.pl
Expect-1.32/examples/expect_calc.pl
Expect-1.32/examples/kibitz/
Expect-1.32/examples/ssh.pl
Expect-1.32/examples/kibitz/Changelog
Expect-1.32/examples/kibitz/kibitz
Expect-1.32/examples/kibitz/kibitz.man
Expect-1.32/examples/kibitz/README
CPAN: File::Temp loaded ok (v0.22)

  CPAN.pm: Going to build S/SZ/SZABGAB/Expect-1.32.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite IO::Pty 1.11 not found.
Warning: prerequisite IO::Tty 1.11 not found.
Generating a Unix-style Makefile
Writing Makefile for Expect
Writing MYMETA.yml and MYMETA.json
---- Unsatisfied dependencies detected during ----
----        SZABGAB/Expect-1.32.tar.gz        ----
    IO::Tty [requires]
    IO::Pty [requires]
Shall I follow them and prepend them to the queue
of modules we are processing right now? [yes] yes
Running make test
  Delayed until after prerequisites
Running make install
  Delayed until after prerequisites
Running install for module 'IO::Tty'
Running make for T/TO/TODDR/IO-Tty-1.12.tar.gz
Fetching with LWP:
  http://mirrors.163.com/cpan/authors/id/T/TO/TODDR/IO-Tty-1.12.tar.gz
Fetching with LWP:
  http://mirrors.163.com/cpan/authors/id/T/TO/TODDR/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/T/TO/TODDR/IO-Tty-1.12.tar.gz ok
IO-Tty-1.12/
IO-Tty-1.12/ChangeLog
IO-Tty-1.12/Makefile.PL
IO-Tty-1.12/MANIFEST
IO-Tty-1.12/META.json
IO-Tty-1.12/META.yml
IO-Tty-1.12/Pty.pm
IO-Tty-1.12/README
IO-Tty-1.12/t/
IO-Tty-1.12/try
IO-Tty-1.12/Tty.pm
IO-Tty-1.12/Tty.xs
IO-Tty-1.12/t/test.t

  CPAN.pm: Going to build T/TO/TODDR/IO-Tty-1.12.tar.gz

Now let's see what we can find out about your system
(logfiles of failing tests are available in the conf/ dir)...
Looking for _getpty()...... not found.
Looking for getpt()........ FOUND.
Looking for grantpt()...... FOUND.
Looking for openpty()...... FOUND.
Looking for posix_openpt(). FOUND.
Looking for ptsname()...... FOUND.
Looking for ptsname_r().... FOUND.
Looking for sigaction().... FOUND.
Looking for strlcpy()...... not found.
Looking for ttyname()...... FOUND.
Looking for unlockpt()..... FOUND.
Looking for libutil.h...... not found.
Looking for pty.h.......... FOUND.
Looking for sys/pty.h...... not found.
Looking for sys/ptyio.h.... not found.
Looking for sys/stropts.h.. not found.
Looking for termio.h....... FOUND.
Looking for termios.h...... FOUND.
Looking for util.h......... not found.
Checking which symbols compile OK...
(sorry for the tedious check, but some systems have not too clean
 header files, to say the least;  ' ' means OK, '-' means not defined
 and '*' has compile problems...)
 B0  B110  B115200  B1200  B134  B150 -B153600  B1800  B19200  B200  B230400  B2400  B300 -B307200  B38400  B460800  B4800  B50  B57609600  BRKINT  BS0  BS1  BSDLY  CBAUD -CBAUDEXT  CBRK -CCTS_OFLOW -CDEL  CDSUSP  CEOF  CEOL -CEOL2  CEOT  CERASE -CESC  CFLUSH  CIBAUD L  CLNEXT  CLOCAL -CNSWTCH -CNUL  CQUIT  CR0  CR1  CR2  CR3  CRDLY  CREAD  CRPRNT  CRTSCTS -CRTSXOFF -CRTS_IFLOW  CS5  CS6  CS7  CS8  STOPB  CSUSP -CSWTCH  CWERASE -DEFECHO -DIOC -DIOCGETP -DIOCSETP -DOSMODE  ECHO  ECHOCTL  ECHOE  ECHOK  ECHOKE  ECHONL  ECHOPRT  EXTA -FIORDCHK  FLUSHO  HUPCL  ICANON  ICRNL  IEXTEN  IGNBRK  IGNCR  IGNPAR  IMAXBEL  INLCR  INPCK  ISIG  ISTRIP  IUCLC  IXANY  IXOFF  IXONLOSE -LDDMAP -LDEMAP -LDGETT -LDGMAP -LDIOC -LDNMAP -LDOPEN -LDSETT -LDSMAP -LOBLK  NCCS  NL0  NL1  NLDLY  NOFLSH  OCRNL  OFDEL  OFILL ONOCR  OPOST -PAGEOUT  PARENB -PAREXT  PARMRK  PARODD  PENDIN -RCV1EN -RTS_TOG  TAB0  TAB1  TAB2  TAB3  TABDLY -TCDSET  TCFLSH  TCGETIOFF  TCIOFLUSH  TCION  TCOFLUSH  TCOOFF  TCOON  TCSADRAIN  TCSAFLUSH  TCSANOW  TCSBRK  TCSETA  TCSETAF  TCSETAW -TCSETCTTY  TCSETS  T -TERM_D40 -TERM_D42 -TERM_H45 -TERM_NONE -TERM_TEC -TERM_TEX -TERM_V10 -TERM_V61  TIOCCBRK -TIOCCDTR  TIOCCONS  TIOCEXCL -TIOCFLUSH -CGETP -TIOCGLTC  TIOCGPGRP  TIOCGSID  TIOCGSOFTCAR  TIOCGWINSZ -TIOCHPCL -TIOCKBOF -TIOCKBON -TIOCLBIC -TIOCLBIS -TIOCLGET -TIOCLSET  CMGET  TIOCMSET  TIOCM_CAR  TIOCM_CD  TIOCM_CTS  TIOCM_DSR  TIOCM_DTR  TIOCM_LE  TIOCM_RI  TIOCM_RNG  TIOCM_RTS  TIOCM_SR  TIOCM_ST  TCOUTQ -TIOCREMOTE  TIOCSBRK  TIOCSCTTY -TIOCSDTR -TIOCSETC  TIOCSETD -TIOCSETN -TIOCSETP -TIOCSIGNAL -TIOCSLTC  TIOCSPGRP -TIOCSSID  T TIOCSTI -TIOCSTOP  TIOCSWINSZ -TM_ANL -TM_CECHO -TM_CINVIS -TM_LCF -TM_NONE -TM_SET -TM_SNL  TOSTOP -VCEOF -VCEOL  VDISCARD -VDSUSP  SE  VINTR  VKILL  VLNEXT  VMIN  VQUIT  VREPRINT  VSTART  VSTOP  VSUSP -VSWTCH  VT0  VT1  VTDLY  VTIME  VWERASE -WRAP  XCASE -XCLUDE -X

>>> Configuration looks good! <<<

Writing IO::Tty::Constant.pm...
DEFINE = -DHAVE_DEV_PTMX -DHAVE_GETPT -DHAVE_GRANTPT -DHAVE_OPENPTY -DHAVE_POSIX_OPENPT -DHAVE_PTSNAME -DHAVE_PTSNAME_R -DHAVE_PTY_H -TERMIOS_H -DHAVE_TERMIO_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for IO::Tty
Writing MYMETA.yml and MYMETA.json
cp Tty/Constant.pm blib/lib/IO/Tty/Constant.pm
cp Tty.pm blib/lib/IO/Tty.pm
cp Pty.pm blib/lib/IO/Pty.pm
Running Mkbootstrap for IO::Tty ()
chmod 644 "Tty.bs"
"/usr/bin/perl" "/usr/share/perl5/ExtUtils/xsubpp"  -typemap "/usr/share/perl5/ExtUtils/typemap"  Tty.xs > Tty.xsc && mv Tty.xsc Tty.c
gcc -c   -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFS -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION="1.12" -DXS_"-I/usr/lib64/perl5/CORE"  -DHAVE_DEV_PTMX -DHAVE_GETPT -DHAVE_GRANTPT -DHAVE_OPENPTY -DHAVE_POSIX_OPENPT -DHAVE_PTSNAME -DHAVE_PTSNAM_SIGACTION -DHAVE_TERMIOS_H -DHAVE_TERMIO_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT Tty.c
rm -f blib/arch/auto/IO/Tty/Tty.so
gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic T/IO/Tty/Tty.so 	
	   -lutil  	
	  
chmod 755 blib/arch/auto/IO/Tty/Tty.so
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Tty.bs blib/arch/auto/IO/Tty/Tty.bs 644
Manifying 3 pod documents
  TODDR/IO-Tty-1.12.tar.gz
  make -- OK
Running make test
Running Mkbootstrap for IO::Tty ()
chmod 644 "Tty.bs"
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'b t/*.t
t/test.t .. # Configuration: -DHAVE_DEV_PTMX -DHAVE_GETPT -DHAVE_GRANTPT -DHAVE_OPENPTY -DHAVE_POSIX_OPENPT -DHAVE_PTSNAME -DHAVE_PTSNVE_SIGACTION -DHAVE_TERMIOS_H -DHAVE_TERMIO_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT
# Checking for appropriate ioctls:
# TIOCNOTTY
# TIOCSCTTY
trying posix_openpt()...
trying grantpt()...
trying unlockpt()...
trying ptsname_r()...
trying to open /dev/pts/4...
t/test.t .. 1/5 #  === Checking if child gets pty as controlling terminal
trying posix_openpt()...
trying grantpt()...
trying unlockpt()...
trying ptsname_r()...
trying to open /dev/pts/4...
t/test.t .. 3/5 
WARNING: when the client closes the slave pty, the master gets an error
(undef return value and $! eq "Input/output error")
instead of EOF (0 return value).  Please be sure to handle this 
in your application (Expect already does).

# Checking basic functionality and how your ptys handle large strings...
#   This test may hang on certain systems, even though it is protected
#   by alarm().  If the counter stops, try Ctrl-C, the test should continue.
trying posix_openpt()...
trying grantpt()...
trying unlockpt()...
trying ptsname_r()...
trying to open /dev/pts/4...
# isatty($master): YES
# isatty($slave): YES
# Child PID = 12438
# Good, your raw ptys can handle at least 530 bytes at once.
t/test.t .. 5/5 sysread(): Input/output error at t/test.t line 151.
Slave got EOF at line 530, byte 0.
t/test.t .. ok   
All tests successful.
Files=1, Tests=5,  3 wallclock secs ( 0.04 usr  0.01 sys    0.08 cusr  0.06 csys =  0.19 CPU)
Result: PASS
  TODDR/IO-Tty-1.12.tar.gz
  make test -- OK
Running make install
Prepending /root/.cpan/build/IO-Tty-1.12-BvmJAD/blib/arch /root/.cpan/build/IO-Tty-1.12-BvmJAD/blib/lib to PERL5LIB for 'install'
Manifying 3 pod documents
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib64/perl5/auto/IO/Tty/Tty.so
Installing /usr/local/lib64/perl5/IO/Tty.pm
Installing /usr/local/lib64/perl5/IO/Pty.pm
Installing /usr/local/lib64/perl5/IO/Tty/Constant.pm
Installing /usr/local/share/man/man3/IO::Tty.3pm
Installing /usr/local/share/man/man3/IO::Tty::Constant.3pm
Installing /usr/local/share/man/man3/IO::Pty.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
  TODDR/IO-Tty-1.12.tar.gz
  make install  -- OK
IO::Pty is up to date (1.12).
Running make for S/SZ/SZABGAB/Expect-1.32.tar.gz
  Has already been unwrapped into directory /root/.cpan/build/Expect-1.32-vx0PVI

  CPAN.pm: Going to build S/SZ/SZABGAB/Expect-1.32.tar.gz

cp lib/Expect.pm blib/lib/Expect.pm
Manifying 1 pod document
  SZABGAB/Expect-1.32.tar.gz
  make -- OK
Running make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'b t/*.t
t/01-test.t .......     # Basic tests...
t/01-test.t ....... 1/14     # Testing exec failure...
t/01-test.t ....... 2/14     # Testing exp_continue...
    # number of timeout calls in 5 sec: 4
t/01-test.t ....... 4/14     # timeout shouldn't destroy accum contents
t/01-test.t ....... 5/14     # Testing -notransfer...
t/01-test.t ....... 6/14     # Testing raw reversing...
    # isatty($exp): YES
    # Called: 3
    # Elapsed time: 6  delay by expect: 4.5
    # Elapsed time: 5  delay by expect: 3.9
    # Elapsed time: 6  delay by expect: 4.3
    # Called: 3
t/01-test.t ....... 7/14     # Check if the raw pty can handle large chunks of text at once
    # ------------------------------------------------------------------------------
    #   The following tests check system-dependend behaviour, so even if some fail,
    #   Expect might still be perfectly usable for you!
    # ------------------------------------------------------------------------------
    # Length: 512
    # Good, your raw pty can handle lines of at least 512 bytes at a time.
    # Status: match
t/01-test.t ....... 8/14     # Check if the default pty can handle large chunks of text at once
    # ------------------------------------------------------------------------------
    #   The following tests check system-dependend behaviour, so even if some fail,
    #   Expect might still be perfectly usable for you!
    # ------------------------------------------------------------------------------
    # Length: 164
    # Good, your default pty can handle lines of at least 164 bytes at a time.
    # Status: match
t/01-test.t ....... 9/14     # Testing controlling terminal...
    # Checking if exit status is returned correctly...
    # soft_close: 0x2A00
t/01-test.t ....... 11/14     # Checking if signal exit status is returned correctly...
    # soft_close: 0x000F
t/01-test.t ....... 12/14 # 
# Checking if EOF on pty slave is correctly reported to master...
# (this fails on about 50% of the supported systems, so don't panic!
#  Expect will work anyway!)
# 
t/01-test.t ....... ok     
t/02-bc.t ......... skipped: See https://rt.cpan.org/Ticket/Display.html?id=98495
t/03-log.t ........ # Test created for https://rt.cpan.org/Ticket/Display.html?id=62359 related to clear_accum
t/03-log.t ........ ok     
t/04-multiline.t .. ok     
t/10-internal.t ... ok     
t/11-calc.t ....... 1/22 # OUTPUT
t/11-calc.t ....... ok     
All tests successful.
Files=6, Tests=97, 66 wallclock secs ( 0.05 usr  0.01 sys    0.53 cusr  0.16 csys =  0.75 CPU)
Result: PASS
  SZABGAB/Expect-1.32.tar.gz
  make test -- OK
Running make install
Prepending /root/.cpan/build/Expect-1.32-vx0PVI/blib/arch /root/.cpan/build/Expect-1.32-vx0PVI/blib/lib to PERL5LIB for 'install'
Manifying 1 pod document
Installing /usr/local/share/perl5/Expect.pm
Installing /usr/local/share/man/man3/Expect.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
  SZABGAB/Expect-1.32.tar.gz
  make install  -- OK

cpan[3]> quit 
No history written (no histfile specified).
Lockfile removed.
[root@dancer-test ~]# 

Note: cpan会自动发现依赖,并且尝试解决依赖,请求同意时要允许

0 人点赞