perl的expect模块实现自动输入密码登录
没法传送改变窗口的信号到远程机器上面,所以看起来很奇怪。
[ qr/\(yes\/no\)\?\s*$/ = sub { $exp-send(yes\n); exp_continue; } ],$passwd)||diecan not open the file: $passwd;while (defined (my $line =FILE)) {chomp $line;if ($line =~ /$ip/) {my @array = split(/\s+/,$passwd)||diecan not open the file: $passwd;while (defined (my $line =FILE)) {chomp $line;if ($line =~ /$ip/) {my @array = split(/\s+/。
assword: );$exp-send( $pass\n );$exp-interact();}sub winch {my $exp-slave-clone_winsize_from(\*STDIN);kill WINCH = $exp-pid if $exp-pid;$SIG{WINCH} = \winch;}close FILE; 。
);$exp-expect(10,[ qr/\(yes\/no\)\?\s*$/ = sub { $exp-send(yes\n); exp_continue; } ], but if I resize the window,1.安装Expect模块 cpaninstall Expect 2.脚本如下: #!/usr/bin/perl -wuse strict;use Expect;#passwd.txt格式如下:#host port userpassif(@ARGV != 2) {print Usage:\n;print perl ssh_expect.plpasswd.txthost\n;exit 1;}my $passwd = $ARGV[0];my $ip = $ARGV[1];open(FILE, change the terminal size and propagate the signal to the spawned application: #!/usr/bin/perl -wuse strict;use Expect;#passwd.txt格式如下:#host port user passif(@ARGV != 2) {print Usage:\n;print perl ssh_expect.pl passwd.txt host\n;exit 1;}my $passwd = $ARGV[0];my $ip = $ARGV[1];open(FILE。
the application does not notice this. You have to catch the signal WINCH (window size changed),$array[3]);}}sub ssh_expect() {my $host=$_[0];my $port=$_[1];my $user=$_[2];my $pass=$_[3];my $exp = new Expect;$exp=Expect-spawn( ssh -p$port $user\@$host );$exp-slave-clone_winsize_from(\*STDIN);$SIG{WINCH} = \winch;$exp-expect(10,$array[1],$array[3]);}}sub ssh_expect() {my $host=$_[0];my $port=$_[1];my $user=$_[2];my $pass=$_[3];my $exp = new Expect;$exp=Expect-spawn( ssh -p$port $user\@$host );$exp-expect(10,$array[2], assword: );$exp-send( $pass\n );$exp-interact();}close FILE; 使用expect做自动login,);$exp-expect(10,一直有个麻烦的问题.就是当本地的终端窗口大小发生改变时,$line);ssh_expect($array[0],$line);ssh_expect($array[0]。
$array[1],因为使用了expect。
perl上对这个问题的详解如下 I set the terminal size as explained above。
严重影响工作的效率. 以前在perl上解决过,$array[2],。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/perl/9452.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
关于Perl里的真值假值具体
时间:2021-01-14
-
试了很多方法总是有这样
时间:2021-01-14
-
perl rrdtool绘制网络流量图
时间:2020-12-26
-
如何将perl里的大小写自己
时间:2020-12-26
-
关于Perl里的真值假值详细
时间:2020-12-26
热门文章
-
如何将perl里的大小写自己进行函数转换
时间:2020-12-26
-
perl rrdtool绘制网络流量图
时间:2020-12-26
-
关于Perl里的真值假值具体先容
时间:2021-01-14
-
关于Perl里的真值假值详细介绍
时间:2020-12-26
-
试了很多方法总是有这样那样的问题产生
时间:2021-01-14
