perl

推荐列表 站点导航

当前位置:首页 > 脚本编程 > perl >

perl的expect模块实现自动输入密码登录

来源:网络整理  作者:  发布时间:2020-12-26 17:05
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

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

perl的expect模块实现自动输入密码登录

2020-12-26 编辑:

没法传送改变窗口的信号到远程机器上面,所以看起来很奇怪。

[ 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

相关文章

风云图片

推荐阅读

返回perl频道首页