有个工具sshpass,虽然不是用perl写的,但是很实用

在 2010年7月22日 下午9:18,Xiaojun Deng <[email protected]>写道:

> 用expect
> 给个例子
>
> #!/usr/bin/perl
> use strict;
> use Expect;
>
> my $timeout = 2;
> my $delay = 1;
> my $cmd = "ssh";
> my @params = qw/202.108.xx.xx -lusername -p22/;
> my $pass = "passwd";
>
> my $exp = Expect->spawn($cmd, @params) or die "Can't spawn $cmd\n";
> $exp->expect($timeout, -re=>'[Pp]assword:');
> $exp->send_slow($delay, "$pass\r\n");
>
> $exp->interact();
> $exp->hard_close();
>
> exit 0;
>
> 2010/7/22 徐卓夫 <[email protected]>:
> > expect脚本做这个不错
> >
> > 在 2010年7月22日 上午8:58,azure wang <[email protected]>写道:
> >>
> >> cpan上有现成的模块  Net::SSH::Perl
> >>
> >> 在 2010年7月22日 上午12:12,Andy Chen <[email protected]>写道:
> >>>
> >>> ssh到某机器,可能需要密码也可能不要,要求能根据shell提示判断。
> >>>
> >>> 发自我的 iPad
> >>>
> >>> --
> >>> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> >>> 要取消订阅此网上论坛,请发送电子邮件至 
> >>> [email protected]<perlchina%[email protected]>
> 。
> >>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
> >>>
> >>
> >>
> >>
> >> --
> >> Azure.Wang
> >>
> >> --
> >> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> >> 要取消订阅此网上论坛,请发送电子邮件至 
> >> [email protected]<perlchina%[email protected]>
> 。
> >> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
> >
> > --
> > 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> > 要取消订阅此网上论坛,请发送电子邮件至 
> > [email protected]<perlchina%[email protected]>
> 。
> > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
> >
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 
> [email protected]<perlchina%[email protected]>
> 。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>
>

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复