my $timeout = 2;
my $cmd = "ftp";
my $exp = Expect->spawn($cmd,"192.168.32.11") or die "Can't spawn $cmd!";
$exp->expect($timeout,-re=>'^Name \(*\):');
$exp->send("administrator\r\n");
$exp->expect($timeout,-re=>'Password:');
$exp->send("arkivio\r\n");
$exp->expect($timeout,-re=>'ftp>');
$exp->send("get policyxml-nfs.xml\r\n");
简单看了一下输出,发现问题是:用户名和密码都被重复输入了3次。这是为什么呢?
ftp> ftp> -bash-3.00# perl test-ftp.pl
Connected to 192.168.32.11.
220 Microsoft FTP Service
Name (192.168.32.11:root): administrator
administrator
administrator
331 Password required for administrator.
Password:
arkivio